How can AnqiCMS efficiently display the latest published article list on the homepage?

Calendar 👁️ 71

How can AnqiCMS efficiently display the latest published article list on the homepage?

In website operation, the homepage as the first station for user access, the activity of its content update often determines whether users are willing to stay and delve deeper into browsing.Especially for content-based websites or corporate blogs, the homepage can dynamically display the latest list of published articles, not only presenting fresh content to visitors in the first time, but also a key factor in enhancing user experience and search engine optimization.So, how do we efficiently achieve this goal in AnQiCMS (AnQiCMS)?

Anqi CMS, with its simple and efficient architecture and flexible template system, makes it very intuitive to display the latest article list on the homepage. The core lies in fully utilizing the system providedarchiveListTemplate tags combined with some key parameters can easily achieve content automation updates.

Firstly, to implement the list of "latest published" articles, we mainly rely onarchiveListThis powerful tag is used to filter and retrieve article data from the database.This tag provides rich parameters, allowing us to precisely control the display of the article.Generally, you would place this tag code in your template file, such as in the main template directory.index.htmlfiles, orindex/index.htmlThis depends on the organization of your current template. The Anqi CMS template syntax is similar to Django, very intuitive, you just need to use{% 标签名 参数 %}to call the function, use{{ 变量名 }}to output content.

Make sure the list displays the latest articles,orderThe parameter is indispensable. We can set it toorder="CreatedTime desc"This means that the system will sort the articles based on the publication time (CreatedTime) in descending order, with the latest articles naturally appearing at the top. Of course, if you prefer to judge the newness of articles based on their ID, you can also useorder="id desc". At the same time, throughlimitParameter, you can flexibly control the number of articles displayed on the homepage, for example, set it tolimit="5"The home page will only display the latest five articles. This mechanism is due to the high-performance Go language underlying architecture of AnQi CMS, even if the number of articles on the website is large, it can still ensure fast response and efficient loading.

Here is a simplified code example of displaying the latest article list on the homepage, which clearly shows how to utilizearchiveListTags:

<section class="latest-articles">
    <h2>最新发布</h2>
    <div class="article-list">
        {% archiveList latestArticles with type="list" order="CreatedTime desc" limit="5" %}
            {% for item in latestArticles %}
            <div class="article-item">
                <a href="{{ item.Link }}" title="{{ item.Title }}">
                    {% if item.Thumb %}
                    <img src="{{ item.Thumb }}" alt="{{ item.Title }}" class="article-thumb">
                    {% endif %}
                    <h3>{{ item.Title }}</h3>
                </a>
                <p class="article-description">{{ item.Description|truncatechars:100 }}</p>
                <div class="article-meta">
                    <span class="article-date">发布于:{{ stampToDate(item.CreatedTime, "2006年01月02日") }}</span>
                    <span class="article-views">浏览量:{{ item.Views }}</span>
                </div>
            </div>
            {% empty %}
            <p>目前还没有文章发布,敬请期待!</p>
            {% endfor %}
        {% endarchiveList %}
    </div>
</section>

In this example,archiveListtag first defines a variablelatestArticlesto store the retrieved article data.type="list"We specified that we were getting a regular list, not a paged list.order="CreatedTime desc"Ensured that the articles were arranged from new to old by publication time, andlimit="5"It limited to displaying only the latest five articles.

In{% for item in latestArticles %}the loop,itemRepresents the data of each article, we can use throughitem.Linkget the article link,item.TitleGet the title,item.DescriptionRetrieve article summaries,item.Viewsto get the view count. Especiallyitem.ThumbIt allows you to display the thumbnail of the article, making the homepage list more vivid and attractive.If the article does not set a thumbnail, this code will also automatically determine and choose not to display the image.

It is worth noting that,item.CreatedTimeis a timestamp, to convert it to the date format we are familiar with, we usedstampToDatethis auxiliary label, and specified"2006年01月02日"Such Go language time format template makes the date display clearer. At the same time,Description|truncatechars:100The filter can elegantly truncate the article summary to a specified length and add an ellipsis at the end, keeping the page neat.

If the website has not published any articles temporarily,{% empty %}The content inside the block will be displayed, avoiding the embarrassment of a blank page, which is a very considerate design.

In addition to the basic list of latest articles, you can also customize according to your needs. For example, if you want to display only the latest articles under a specific category, you can simply inarchiveListthe tag withcategoryId="你的分类ID"The parameter. The multi-site management feature of AnQi CMS also means that if you are operating multiple websites, you can also go throughsiteIdThe parameter specifies the content to be called from different sites, realizing flexible content display across sites.

In addition, the 'Time Factor-Scheduled Publication Function' of Anqi CMS is also closely related to this.You can edit the article in advance, set the future publication time, and the system will automatically publish it after reaching the specified time and immediately update it to the latest article list on the homepage, greatly improving the flexibility and automation of content operation, allowing you to plan content layout in an orderly manner.

In summary, Anqi CMS, through its intuitive template tags and high-performance backend support, allows website operators to easily and efficiently display the latest published article list on the homepage.This not only enhanced the dynamic feel and user experience of the website, but also laid a solid foundation for content marketing and SEO optimization.


Frequently Asked Questions (FAQ)

  1. Question: How to exclude articles of a specific category when displaying the latest articles on the homepage?Answer: If you want to exclude certain categories that you do not want to display in the latest article list on the homepage, you can usearchiveListlabel'sexcludeCategoryIdthe parameters. For example,{% archiveList latestArticles with type="list" order="CreatedTime desc" limit="5" excludeCategoryId="1,3" %}This will exclude articles under categories with IDs 1 and 3.

  2. Ask: I have published a new article, but the homepage did not update immediately. What is the reason?Answer: The AnQi CMS backend has the "Update Cache" feature, which is usually automatically updated after the article is published.If the homepage does not immediately display the latest articles, it may be due to server or browser caching.You can try to click the 'Update Cache' button on the Anqicms CMS backend to clear the system cache, and you can also clear your browser cache (Ctrl+F5 or Cmd+Shift+R) to force refresh the page.

  3. Ask: Besides the publish time, can I sort the latest articles in other ways? For example, by article popularity?Answer: Of course you can.archiveListlabel'sorderThe parameters are very flexible. In addition toorder="CreatedTime desc"(Sorted by publish time in reverse) ororder="id desc"(Sorted by ID in reverse), you can also useorder="views desc"Sort articles by the number of views (popularity) in descending order to display the most popular articles. If you want to display the manually set order by the editor, you can useorder="sort desc".

Related articles

How can you dynamically obtain and display the current year or other time information in the AnqiCMS template?

In website operation, we often need to dynamically display the current year, date, or time on the page, such as the copyright information in the footer, the publication or update time of articles, etc.This information, if manually updated, is not only time-consuming and labor-intensive, but also prone to errors.Fortunately, AnqiCMS provides a concise and efficient method for you to easily implement the acquisition and display of these dynamic time information in the template.### Dynamically retrieve and display the current year or other time information In the AnqiCMS template, to retrieve and display the current year or any format of the current time, we can use the built-in

2025-11-09

How to display traffic or crawler access data charts on the front end of AnqiCMS's background data statistics function?

Understanding website traffic and user behavior is crucial for operators.AnqiCMS as an efficient enterprise-level content management system provides detailed data statistics and crawling monitoring functions in the background.This data can not only help us analyze the performance of the website and optimize the content strategy, but also has the potential to provide more intuitive information to users or visitors in specific scenarios through the display of charts on the front end.

2025-11-09

How to automatically parse a URL string into a clickable a tag in AnqiCMS template for convenient browsing?

When operating a website, we often add some URLs in articles, product descriptions, or single-page content, which may be recommended external resources or references to other content within the site.But if these URLs are just displayed in plain text, users will have to copy and paste to access them, which is inconvenient and also affects the reading experience.AnqiCMS has fully considered this point and provided us with a very convenient way to automatically convert plain text URLs in the content into clickable links, greatly enhancing the convenience of user browsing and the professionalism of the website.

2025-11-09

How can I truncate a string or HTML content in AnqiCMS template and add an ellipsis to control the display length?

In website operation, the way content is presented has a crucial impact on user experience and information transmission efficiency.Whether it is the introduction of the article list, the abstract of the product description, or other text content that needs to be previewed, reasonable control of the display length and the use of ellipses can not only maintain the page's neat and beautiful appearance, but also guide users to click and view more details.AnqiCMS as an efficient and flexible content management system, provides a variety of powerful template tags and filters, making the control of content length extremely simple and intelligent.Why do we need to truncate content and add an ellipsis

2025-11-09

How to use AnQi CMS template tags to call the article content under a specific category and perform pagination display?

In website content operation, we often need to display a list of articles under a specific category on a single page, and in order to provide a better user experience and content structure, pagination functions are usually used in conjunction.Strong and easy-to-use template tags are provided by AnQi CMS, which can help us easily meet this requirement. ### The core of article content call: `archiveList` tag To call the article content under a specific category, AnQi CMS provides the core tag `archiveList`. This label is very flexible

2025-11-09

In AnQi CMS, how should the article detail page correctly display the article title, content, and related information?

AnQiCMS (AnQiCMS) provides powerful and flexible content management features, especially when building article detail pages, which can help us efficiently present high-quality content.A well-designed article detail page can not only clearly display the core information of the article, but also effectively improve the user's reading experience and the stickiness of the website through the recommendation of related content. ### Article Title and Core Content: The Soul of the Page The core of the article detail page in Anqi CMS is the article title and main content.

2025-11-09

Under multi-site management, how to ensure that the independent content of each site is displayed correctly?

The practice of independent content display for multiple sites of AnQi CMS: Ensuring the unique style of each site In today's ever-changing digital world, many enterprises and content operators may need to manage multiple websites at the same time, whether it is to distinguish brands, sub-divide markets, or meet different business needs.AnQiCMS (AnQiCMS) provides an efficient and convenient solution for such needs with its powerful multi-site management function.

2025-11-09

How to customize the content model in Anqi CMS to achieve personalized product display?

When building a successful website, especially for enterprises that need to display a variety of products, the personalization and precise presentation of content are crucial.Traditional website content management systems often provide fixed or limited content types, which may not be sufficient when facing products with different attributes and display requirements.AnQiCMS (AnQiCMS) understands this pain point, through its powerful customizable content model function, it provides users with flexible and efficient solutions, making personalized product display easily accessible.### AnQi CMS Content Model

2025-11-09