How to display the previous and next article links of the current article in AnQiCMS template?

Calendar 81

In content operation, providing navigation to the previous and next articles for each article can not only significantly improve the user's reading experience, but also effectively increase the internal links of the website, which is of great benefit to search engine optimization (SEO).AnQi CMS with its flexible template system makes the implementation of this feature intuitive and efficient.By using a brief template tag, you can easily integrate this practical navigation mechanism on the article detail page.

Core Function Analysis: Tags of previous and next documents

The AnQi CMS is built-in with special template tags for retrieving the previous and next articles of the current article, respectivelyprevArchiveandnextArchiveThese tags are intended to be used on the article detail page, the system will automatically identify and provide data for adjacent articles based on the current article's order in the list.

They use a very simple method, do not require complex parameter settings, just define a variable name within the tag to carry the data. For example, you can use{% prevArchive prev %}To get information about the previous article, and byprevthis variable to access its data; similarly,{% nextArchive next %}is used to get information about the next article, bynextvariable to operate.

Once defined,prevornextSuch a variable, we can pass through{{变量名.字段名}}In the form to access the various information of the previous or next article

Variables and available fields inside the tag

InprevandnextIn the variable, AnQi CMS provides a rich set of article-related fields, which you can flexibly call according to your template design requirements. Some of the most commonly used fields include:

  • Document title (Title)Description: Used to display the article name.
  • Document link (Link)Description: Used to generate clickable navigation links.
  • Document cover thumbnail (Thumb): If your design needs to display a preview of the previous or next article, this field is very useful.

Of course, you can also access other fields, such asId(Document ID),Description(Document Description),CategoryId(Document Category ID),Views(Document Views) evenCreatedTime(Article Publish Time). For time fields, if formatting is required, it can be配合stampToDateFilter usage, for example{{stampToDate(item.CreatedTime, "2006-01-02")}}.

Actual application: write template code

Now, let's see how to actually write these navigation links in your Anqi CMS template. Usually, this code is placed inarchive/detail.htmlAt the bottom, below the article content of the document details template (or your custom template).

The following is a basic example, it checks for the existence of the previous or next article and displays its title and link:

<nav class="article-pagination">
    <div class="prev-article">
        {% prevArchive prev %}
        {% if prev %}
            上一篇:<a href="{{ prev.Link }}">{{ prev.Title }}</a>
        {% else %}
            <span>没有上一篇文章了</span>
        {% endif %}
        {% endprevArchive %}
    </div>
    <div class="next-article">
        {% nextArchive next %}
        {% if next %}
            下一篇:<a href="{{ next.Link }}">{{ next.Title }}</a>
        {% else %}
            <span>没有下一篇文章了</span>
        {% endif %}
        {% endnextArchive %}
    </div>
</nav>

To provide a more intuitive visual experience, you can also consider adding a thumbnail to the article.This allows users to have a general understanding of the content before clicking.This is an example that includes a thumbnail and is more comprehensive:

`twig

Related articles

How to display the detailed content of a specified article or product in AnQiCMS?

AnQiCMS (AnQiCMS) is an efficient and flexible content management system that provides an intuitive way to manage and display various types of content.When you want to display a specific article, product details, or any independent content page created through a content model on a website, the core lies in using its powerful template tag features.AnQiCMS refers to the articles, products, and other independently displayed content on the website as 'documents' (archive).

2025-11-08

How to retrieve a list of articles or products in AnQiCMS and support pagination display?

How to efficiently display articles or product lists in a content management system and provide users with a smooth pagination experience is a common concern for website operators.AnQiCMS is a system developed based on the Go language, which makes everything intuitive and efficient through its flexible and powerful template tag system.Next, we will discuss how to take advantage of the built-in features of AnQiCMS to easily implement the list display and pagination functions of articles or products.

2025-11-08

How to get and display the content and title of a specific single page in AnQiCMS?

In AnQiCMS, a single page is a very practical part of the website structure, usually used to display static content such as "About Us", "Contact Information", etc.As a content operator, you may often need to retrieve and display the content and titles of specific single pages at different locations on the website.AnQiCMS provides an intuitive and powerful template tag, making this process very simple. ### Understanding Single Page in AnQiCMS One of the design philosophies of AnQiCMS is the high customizability of content.

2025-11-08

How to display the list and links of all single pages in AnQiCMS template?

In AnQiCMS, wanting to display a list and links of all single pages in a website template is actually a very common requirement, such as you may want to place a 'site map' or 'quick link' area at the bottom of the website, or you may need to list all 'service items' single pages in the sidebar.AnQiCMS provides a simple and powerful template tag that allows you to easily achieve this.### Understanding Single Page and Its Role In AnQiCMS, a single page (Page) is usually used to publish content that is relatively fixed

2025-11-08

How to display related article recommendations on the AnQiCMS article detail page?

In website operation, the related article recommendation function on the article detail page can not only effectively improve the user's browsing depth within the site, reduce the bounce rate, but also guide users to discover more valuable content, indirectly improving the overall SEO performance of the website.AnQiCMS as a content management system that focuses on efficiency and scalability, provides flexible template tags, making it intuitive and convenient to implement this function. Let's discuss together how to elegantly implement related article recommendations on the article detail page of AnQiCMS.

2025-11-08

How to dynamically display custom parameter fields of articles or products in AnQiCMS?

When building and operating a website, we often need to display more information than just the title and content, such as product models, colors, inventory, or the author, source, and publishing platform of the article.AnQiCMS knows the importance of personalized content display, and therefore provides a highly flexible custom parameter field function, making website content management and frontend display both powerful and convenient.Next, let's delve deeper together on how to make full use of this feature in AnQiCMS, making your website content dynamic.### First Step

2025-11-08

How to use the filtering feature of AnQiCMS to display a document list under specific conditions?

How to manage a large amount of content in AnQiCMS and allow users to quickly find the information they need is one of the key factors in content operation.Fortunately, AnQiCMS provides powerful filtering functions, allowing you to flexibly display document lists according to specific conditions, thereby greatly enhancing the website's user experience and content search efficiency. ### Clearly define your filtering requirements: Starting from the backend content model To make use of AnQiCMS's filtering feature, you first need to clarify the conditions through which you want users to search for content.

2025-11-08

How to list all Tag tags in the AnQiCMS template?

In Anqi CMS, using the template function to display all Tag tags on the website is an important operation that helps improve content discoverability and website SEO.AnQiCMS as an efficient content management system provides an intuitive and flexible tag (Tag) management mechanism, allowing users to easily list this content in website templates. ### Learn about AnQiCMS's Tag Function In AnQiCMS, tags (Tag) can be seen as topics or keywords that connect different content.They do not follow a strict hierarchical structure like categories

2025-11-08