How to implement the display of previous and next document links in AnQiCMS templates?

Calendar 👁️ 59

When browsing website content, users often want to be able to navigate easily between related articles.Whether it is to find more information or simply enjoy a smooth reading experience, the 'Previous' and 'Next' document links play a crucial role.They can effectively increase users' stay time on the website, reduce the bounce rate, and also have a positive impact on the internal link structure of the website and search engine optimization (SEO), helping search engines better understand the relevance of the website content.

Core feature analysis: AnQiCMS' document tags before and after

AnQiCMS has fully considered this requirement in template design, providing simple and efficient tags that allow content operators to easily implement the display of "Previous" and "Next" links on document detail pages. This function mainly depends on two built-in template tags:prevArchiveandnextArchive.

These tags are specifically designed for the (Archive) model of documents, and can automatically search and return information about the previous or next document in the context of the current document.Use them, you do not need to write complex logic to determine the sorting of documents or to find nearby data, AnQiCMS has encapsulated this complexity within the tags.They will intelligently judge adjacent documents based on the default document sorting (usually publication time or ID) and provide their titles, links, and other key information.

How to call in the template?

Usually, you will be in the template file of the document detail page (such asarchive/detail.htmlOr add these links to a custom document template. The basic call method is very intuitive, you can wrap them in{% prevArchive ... %}and{% nextArchive ... %}Tags are in pairs. It is important that not all documents have a previous or next one (for example, the first article in a series does not have a previous one, and the last article does not have a next one), so we usually combine conditional judgments.{% if ... %}Ensure that links are only displayed when there is content, thus avoiding empty links or unnecessary text on the page.

Here is the basic code structure to display the titles and links of the previous and next documents:

<div class="article-navigation">
    {# 上一篇文档 #}
    {% prevArchive prev %}
    <div class="prev-article">
        {% if prev %}
        <a href="{{ prev.Link }}">{{ prev.Title }}</a>
        {% else %}
        <span>没有上一篇了</span>
        {% endif %}
    </div>
    {% endprevArchive %}

    {# 下一篇文档 #}
    {% nextArchive next %}
    <div class="next-article">
        {% if next %}
        <a href="{{ next.Link }}">{{ next.Title }}</a>
        {% else %}
        <span>没有下一篇了</span>
        {% endif %}
    </div>
    {% endnextArchive %}
</div>

This code will first try to retrieve the data of the previous document, ifprevthe variable exists, thendivThe element displays its title and link. If it does not exist, a friendly prompt message will be displayed. The logic of the next document is the same, throughnextvariables to determine and render.

Enhance user experience: show thumbnails and more information

To improve user experience, you can not only display the document title, but also introduce other document information such as thumbnails (Thumb) or descriptions (Description).prevandnextThese variables contain rich document fields, similar toarchiveDetailthose available in the tags, for exampleId/Title/Link/Description/Thumbetc.

For example, if you want to display a thumbnail of the previous or next document next to the link, you can modify the template code like this:

<div class="article-navigation enhanced">
    {# 上一篇文档(包含缩略图) #}
    {% prevArchive prev %}
    <div class="prev-article">
        {% if prev %}
        <a href="{{ prev.Link }}">
            {% if prev.Thumb %}<img src="{{ prev.Thumb }}" alt="{{ prev.Title }}" class="article-thumb" />{% endif %}
            <span class="article-title">{{ prev.Title }}</span>
        </a>
        {% else %}
        <span class="no-article">没有上一篇了</span>
        {% endif %}
    </div>
    {% endprevArchive %}

    {# 下一篇文档(包含缩略图) #}
    {% nextArchive next %}
    <div class="next-article">
        {% if next %}
        <a href="{{ next.Link }}">
            <span class="article-title">{{ next.Title }}</span>
            {% if next.Thumb %}<img src="{{ next.Thumb }}" alt="{{ next.Title }}" class="article-thumb" />{% endif %}
        </a>
        {% else %}
        <span class="no-article">没有下一篇了</span>
        {% endif %}
    </div>
    {% endnextArchive %}
</div>

This code will display the title and link while checking if there is a thumbnail (prev.Thumbornext.ThumbIf there is, it will be displayed together, thus providing a more intuitive navigation prompt.You can flexibly adjust the layout and style of these elements according to your design needs, such as controlling the thumbnail size and title color through CSS.

Cautionary notes and **practice

When applying these tags, it is recommended to place them below the document content area, or as a separate navigation module.A reasonable layout helps users naturally discover these jump links without interfering with the reading of the main content.At the same time, don't forget to add appropriate styles to these links through CSS to make them visually clear and identifiable, enhancing the click intention, for example, using left and right arrow icons or different background colors to distinguish them.

AnQiCMS will automatically determine the "previous" and "next" articles based on the category (Category) and publication order of the current document.This means that as long as your document is published in accordance with the regular process and has a clear classification, these tags will work normally.If the document does not have an explicit sort order or classification, AnQiCMS may sort it by default based on its internal ID or publication time.Ensure that your content management strategy effectively utilizes this automatic sorting mechanism.

Summary

provided by AnQiCMSprevArchiveandnextArchiveTags, adding navigation before and after the document content of the website becomes very simple.This greatly improves the user's browsing experience and also builds a more tightly integrated internal link structure for the website, which is very beneficial for the overall health and search engine performance of the website.Make good use of these tags, combining them with your template design, can make your website content more attractive and better serve your audience.


Frequently Asked Questions (FAQ)

Q1: Why doesn't my document detail page display the previous or next link?

A1: This may be because the current document indeed does not have a previous or next one, for example, it is the first or last one in the category. In this case,prevornextThe variable will be empty, in the template{% if %}The condition will not be met. Moreover, please check your template code to ensure{% if prev %}and{% if next %}Such condition judgment correctly includes the link display logic, and the label spelling is correct.

Q2: What is the basis for the sorting of 'Previous' and 'Next' articles? Can I change this sorting method?

A2: AnQiCMS will sort the previous and next documents based on the publication time of the document or internal ID, and they will be searched based on the category context of the current document to ensure navigation to adjacent documents in the same category. Currently,prevArchiveandnextArchiveThe tag itself does not provide a direct way to modify the sorting parameters, they depend on the system default

Related articles

How to use the AnQiCMS document list tag to display content for specific categories or recommended attributes?

In AnQi CMS, efficiently managing and displaying website content is the key to improving user experience and website operation effectiveness.Whether you want to display the latest articles of a specific category on the homepage or highlight products with the "recommended" attribute, the document list tag (`archiveList`) provided by AnQiCMS is the core tool to meet these needs.Its flexible parameter configuration allows us to accurately control content retrieval, transforming technical details into easily accessible operational strategies.

2025-11-08

How to display dynamic breadcrumb navigation in AnQiCMS and customize the home page name?

In website content management, breadcrumb navigation plays a crucial role.It not only helps visitors clearly understand their position on the website, provides a convenient path to return to the upper page, but also reflects the hierarchical structure of the website from the side, which is greatly beneficial to user experience and search engine optimization.AnQiCMS as a powerful content management system naturally provides a flexible way to manage and display this kind of navigation.

2025-11-08

How to integrate and display Markdown, mathematical formulas, and flowcharts correctly on the AnQiCMS page?

In AnQiCMS, adding Markdown, mathematical formulas, and flowcharts to content greatly enhances its expressiveness and readability, especially for technical documents, educational materials, or data analysis reports.AnQiCMS as an efficient content management system, provides flexible mechanisms to support these modern content display needs. To implement the correct display of Markdown, mathematical formulas, and flowcharts on the AnQiCMS page, it mainly involves enabling backend settings and the necessary introduction of frontend templates.Here are the detailed steps and some practical suggestions

2025-11-08

How does AnQiCMS ensure the display quality of image resources and perform automatic compression and WebP conversion?

In the era where content is king, the image resources on the website play a crucial role.They not only directly affect the beauty of the page, but are also key factors in determining the loading speed and user experience of the website.For operators, how to ensure the display quality of images while also taking into account the performance and storage costs of the website is undoubtedly a question worthy of reflection.AnQiCMS (AnQiCMS) is well-versed in this, providing a comprehensive image resource management and optimization strategy, aimed at helping users easily master this challenge.The foundation for ensuring the quality of image display

2025-11-08

How to display custom field content on the AnQiCMS document detail page?

When managing website content in AnQiCMS, we often encounter the need to add some unique information for different types of documents (such as articles, products, etc.).AnQi CMS provides flexible content model features, allowing us to customize fields to meet these personalized needs.How can these custom fields be displayed on the document detail page of the website after they are created and filled with data? This is actually simpler than you imagine, AnQiCMS's powerful template tag system provides us with various convenient ways to achieve this.--- ###

2025-11-08

How to display the list of related documents in AnQiCMS, what is the logic?

How to effectively guide users to discover more interesting content in a content management system is the key to improving user experience and website depth.AnQiCMS handles the 'related document list' feature by providing a flexible and intelligent mechanism that allows us to easily display other articles or products closely related to the current content on the website. This not only helps to extend the user's stay on the website but also optimizes the search engine crawling efficiency through internal links.### AnQiCMS

2025-11-08

How to use AnQiCMS tags to display the document list under a specific Tag?

In AnQiCMS, tags are a powerful content organization method that helps us associate content with different categories and models more flexibly.Using labels appropriately can not only optimize the SEO performance of a website, but also significantly improve the user's experience in discovering content on the website.When we want to focus on displaying all relevant documents under a specific tag, AnQiCMS provides a set of intuitive and efficient template tags to meet this need.This article will introduce in detail how to use the built-in template tags of AnQiCMS

2025-11-08

How to display user comment lists and implement pagination in AnQiCMS?

In website content operation, user comments are an important part of enhancing interactivity and activity, and reasonable pagination can ensure that the comment list is both complete and loads smoothly.AnQiCMS (AnQiCMS) provides powerful and flexible template tags, allowing you to easily display and manage user comments on the front-end page, and implement pagination functionality for the comment list.

2025-11-08