How to use the `prevArchive` and `nextArchive` tags to navigate to adjacent documents in the article detail page?

Calendar 👁️ 66

In today's content-driven era, the user experience of a website's article detail page is particularly important.When the reader is immersed in an excellent article, if they can navigate smoothly to related or adjacent articles, not only can it extend their stay on the website and increase the page views, but it can also indirectly optimize the search engine crawling and ranking through the internal link structure.AnQi CMS is an efficient and SEO-friendly content management system that fully considers these details and provides simple and intuitive template tags to help us easily achieve this function.

Today, we will delve into how to cleverly utilize the built-in features in the Anqi CMS article detail page.prevArchiveandnextArchiveTags, providing seamless navigation to the previous and next document for your readers.

The importance of adjacent document navigation.

Imagine you've finished reading an interesting article and can't find the next recommended content, you might just close the page.If the bottom of the page has clear 'Previous' and 'Next' links, guiding you to continue exploring, you are likely to click and thus discover more interesting content.This design not only improves the fluidity of users within the website and reduces the bounce rate, but more importantly, it provides clear internal link paths for search engine spiders, which helps to better understand the website structure and is very beneficial for SEO optimization.Aanqi CMS is based on such thinking and provides these two powerful template tags.

Get to knowprevArchiveandnextArchiveTag

The AnQi CMS template system uses a syntax similar to the Django template engine, which is simple and powerful.prevArchiveandnextArchiveIs a built-in template tag specifically used for article detail pages, which is used to obtain the data of the "previous" and "next" adjacent documents of the current document.These tags are smart, they will automatically determine the previous and next articles based on the sorting of the current article in the category, without us needing to manually pass any article ID or category information.

Basic syntax structure:

Anqi CMS template tags usually start with{%and ends with%}end, while variables are used.{{and}}.prevArchiveandnextArchiveAs a functional tag, an end tag is needed{% endprevArchive %}and{% endnextArchive %}to define its scope

{# 获取上一篇文档 #}
{% prevArchive 变量名 %}
    {# 在这里处理上一篇文档的数据 #}
{% endprevArchive %}

{# 获取下一篇文档 #}
{% nextArchive 变量名 %}
    {# 在这里处理下一篇文档的数据 #}
{% endnextArchive %}

Generally, we will变量名is set toprevandnextso that they can be clearly identified as representing the document

How to use them on the article detail page?

To be on the article detail page (usuallydetail.htmlOr customize the article detail template) add the previous/next navigation, simply insert these tags into the position where you want to display the navigation, such as the bottom of the article content.

The simplest navigation implementation: only display titles and links

The basic navigation usually only contains article titles and links to the articles.But please note that not all articles have a previous or next one (for example, the first article in a category does not have a previous one, and the last article does not have a next one).Therefore, we strongly recommend coordinating when using these tagsifUse logical judgments to handle these edge cases, to avoid displaying empty links or unnecessary placeholders on the page

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

In this code block:

  • We use separatelyprevArchiveandnextArchiveTag to get adjacent documents.
  • prevandnextIs the variable we define for these document data.
  • {% if prev %}and{% if next %}Ensure that the link will be rendered only when there are adjacent documents.
  • {{ prev.Link }}and{{ next.Link }}Used to output the document URL.
  • {{ prev.Title }}and{{ next.Title }}Used to output the document title.

Enhance user experience: Add thumbnails and descriptions

To make navigation more intuitive and attractive, you can further utilizeprevArchiveandnextArchiveOther fields provided by the tag, such as document thumbnail (Thumb) and brief descriptionDescription)

Here is a navigation example that includes a thumbnail and a title:

<div class="article-pagination-enhanced">
    <div class="prev-article-item">
        {% prevArchive prev %}
            {% if prev %}
                <a href="{{ prev.Link }}" title="上一篇:{{ prev.Title }}">
                    {% if prev.Thumb %}<img src="{{ prev.Thumb }}" alt="{{ prev.Title }}" />{% endif %}
                    <span>上一篇:{{ prev.Title }}</span>
                    {% if prev.Description %}<p>{{ prev.Description|truncatechars:50 }}</p>{% endif %}
                </a>
            {% else %}
                <span class="no-article">没有上一篇了</span>
            {% endif %}
        {% endprevArchive %}
    </div>

    <div class="next-article-item">
        {% nextArchive next %}
            {% if next %}
                <a href="{{ next.Link }}" title="下一篇:{{ next.Title }}">
                    {% if next.Thumb %}<img src="{{ next.Thumb }}" alt="{{ next.Title }}" />{% endif %}
                    <span>下一篇:{{ next.Title }}</span>
                    {% if next.Description %}<p>{{ next.Description|truncatechars:50 }}</p>{% endif %}
                </a>
            {% else %}
                <span class="no-article">没有下一篇了</span>
            {% endif %}
        {% endnextArchive %}
    </div>
</div>

In this enhanced example, we added:

  • {% if prev.Thumb %}and{% if next.Thumb %}To determine if there is a thumbnail and display{{ prev.Thumb }}or{{ next.Thumb }}.
  • {% if prev.Description %}and{% if next.Description %}To display the document description and usetruncatechars:50The filter truncates it to the first 50 characters to maintain formatting.

prevArchiveandnextArchiveThe tags support a very rich set of fields, including:Id(document ID),Title(Title),Link(Link),Keywords(Keyword),Description(Description),CategoryId(Category ID),Views(Views),Logo(Cover main image),Thumb(Cover thumbnail),CommentCount(Number of comments),CreatedTime(Published time),UpdatedTime(Updated time) et al. You can freely choose and combine these fields according to the template design requirements.

Summary

Of Security CMSprevArchiveandnextArchiveThe tag provides an extremely convenient tool for website content operation, allowing you to implement professional-level adjacent document navigation functions on the article detail page without writing complex code.This can not only significantly improve the user's browsing experience and reduce the website bounce rate, but also effectively optimize the internal link structure, helping your website perform better in search engines.

Make good use of these tags,

Related articles

How to implement hierarchical display and nested calling of the `categoryList` tag?

Building a clear and organized website navigation in AnQiCMS is crucial for improving user experience and website accessibility, especially when dealing with multi-level categories.The `categoryList` tag was created for this purpose, providing powerful features to help us flexibly display the hierarchical structure of categories and make fine-grained nested calls.

2025-11-07

How to retrieve the title, content, image, and custom fields of a specific document using the `archiveDetail` tag?

How to use the `archiveDetail` tag in AnQiCMS to finely control the display of document content?AnQiCMS as an efficient and flexible content management system, one of its core advantages lies in its powerful content display capabilities.For each independent article, product detail, or any other 'document' type of content on the website, we hope to fine-tune their display methods on the front page.This is the place where the `archiveDetail` tag really shines.

2025-11-07

How to precisely filter and display a document list with specific categories, models, or recommended attributes using the `archiveList` tag?

In AnQi CMS, the `archiveList` tag is the core tool for building dynamic content lists, allowing you to flexibly extract and display the content you want from the website's document library.Whether it is to display the latest articles under a specific category, or popular products under a certain content model, or special document topics with specific recommendation attributes, `archiveList` can help you accurately meet these needs through its rich parameter configuration.### Accurately locate content: Classification, Model and Recommendation Attributes First

2025-11-07

How to dynamically display data using Django-style tags and variables in AnQiCMS templates?

AnQiCMS provides a flexible and powerful template system, which adopts a syntax style similar to the Django template engine, making experienced developers able to get started quickly, and it is also very intuitive, even users who are not familiar with template language can dynamically present website content through simple learning.This system, with its concise labels and variable usage, makes data interaction with the front-end page efficient and easy to manage.To fully utilize the AnQiCMS template for dynamic data display, we need to understand its core syntax structure: variables, tags, and filters

2025-11-07

How to get and paginate the display of all relevant documents under a specific `tagDataList` tag?

When managing content in Anqi CMS, tags (Tag) are an important tool for organizing and categorizing information.It can not only help users quickly find relevant content, but also significantly improve the internal link structure and SEO performance of the website.When it is necessary to display all relevant documents under a specific tag and to manage pagination, the `tagDataList` tag becomes an indispensable core function.

2025-11-07

How to correctly configure the `pagination` tag to generate a functional pagination navigation on the list page?

In website content management, configuring a fully functional pagination navigation for the list page is a key factor in improving user experience and optimizing the website structure.AnqiCMS (AnqiCMS) provides a simple and powerful `pagination` tag, allowing developers to easily meet this need.To make the `pagination` tag generate the pagination navigation correctly on the list page, it is first necessary to understand its mechanism and the collaborative relationship with content list tags (such as `archiveList`).

2025-11-07

How to use the `stampToDate` tag to format a timestamp into a custom date and time format?

Good, I'm glad to deeply interpret the `stampToDate` tag of AnQiCMS, helping you easily control the time display on the website. --- ## Flexible Time Mastery: Customize Date and Time Format with AnQiCMS `stampToDate` Tag The way dates and times are displayed on a website often directly affects user experience and the clarity of information communication in content management.A concise and readable date format allows visitors to quickly understand the timeliness of the content. AnQiCMS

2025-11-07

How to dynamically generate page title, keywords, and description with the `tdk` tag and flexibly control whether to include the website name?

In website operation, the page title (Title), keywords (Keywords), and description (Description), which we commonly refer to as TDK, are the foundation of search engine optimization.They can not only help search engines understand the page content, but are also key factors to attract users to click.AnQiCMS (AnQiCMS) fully understands the importance of TDK, and through its powerful template tag system, especially the versatile `tdk` tag, makes dynamic generation and flexible control of page TDK easy and efficient.

2025-11-07