How `prevArchive` and `nextArchive` tags display the link and title of the previous/next document?

Calendar 👁️ 69

When browsing website content, users often want to be able to easily navigate to related or adjacent articles from the current page.This kind of previous/next navigation not only can significantly improve user experience, but also can play an active role in SEO, guiding search engine spiders to more deeply crawl website content.prevArchiveandnextArchive.

These tags are designed specifically for the document detail page of AnQiCMS, they can intelligently recognize the current document and find adjacent documents in the timeline or sorting.It is very intuitive to use, you do not need to pass any parameters, the system will automatically judge the context.{% prevArchive prev %}Attempts to retrieve the previous document of the current document and assign it toprevthe variable; similarly,{% nextArchive next %}Attempts to retrieve the next document information and assign it tonextVariable.

Once we obtain these variables, we can access various properties within them, such as the document'sId(ID),Title(Title),Link(Link),Thumb(thumbnail) evenDescription(description) etc. These properties are related toarchiveDetailTags available fields are basically consistent, making content display more flexible.

Display links and titles of the previous/next document

The most common usage is to display a simple text link that the user can click on to directly navigate.However, in practical application, we also need to consider an important situation: if the current document is the first or last document in the category, the previous or next document may not exist.ifJudgment, we can use it to elegantly handle this situation.

Here is a basic template code example showing how to add previous and next text links at the bottom of a document detail page:

<div class="article-navigation">
    <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>
</div>

In this code block,{% prevArchive prev %}and{% nextArchive next %}First, try to get the adjacent documents. IfprevornextThe variable exists (i.e., the corresponding document is found), and we will render a one that includes the document title and link<a>Label.On the contrary, if the document does not exist, it will display a friendly prompt message, such as 'No previous article' or 'No next article', ensuring that the page can display normally in any case and improve the user experience.

Combined with thumbnails to enhance the visual effect

To make navigation more attractive, you can also choose to display a thumbnail of the document next to the link.ThumbThe field provides the thumbnail URL of the document. This is particularly useful for product detail pages or articles with illustrations.

The following code demonstrates how to add a thumbnail to the previous/next navigation:

<div class="article-navigation-visual">
    <div class="prev-article-thumb">
        {% prevArchive prev %}
        {% if prev %}
            <a href="{{ prev.Link }}">
                {% if prev.Thumb %}<img src="{{ prev.Thumb }}" alt="{{ prev.Title }}" />{% endif %}
                <span>上一篇:{{ prev.Title }}</span>
            </a>
        {% else %}
            <span>没有上一篇了</span>
        {% endif %}
        {% endprevArchive %}
    </div>
    <div class="next-article-thumb">
        {% nextArchive next %}
        {% if next %}
            <a href="{{ next.Link }}">
                <span>下一篇:{{ next.Title }}</span>
                {% if next.Thumb %}<img src="{{ next.Thumb }}" alt="{{ next.Title }}" />{% endif %}
            </a>
        {% else %}
            <span>没有下一篇了</span>
        {% endif %}
        {% endnextArchive %}
    </div>
</div>

We use it here as well:{% if prev.Thumb %}To check if the thumbnail exists, to avoid displaying a broken image icon when there is no image.In this way, we can create richer and more attractive content navigation.

These navigation elements are usually placed at the bottom of the document detail page, adjacent to the article content or comments section, providing users with a natural content flow exit.A reasonable layout and design can guide users to stay longer on the website and discover more valuable content.

Use tips

  • Clear guidance:Clearly mark 'Previous' and 'Next' to make it clear to users.
  • Visual Integration:Ensure that the style of navigation links is consistent with the overall design style of the website, without being abrupt.
  • Robust handlingAlways use{% if %}Determine to handle cases where there is no previous or next article, to avoid page display errors or interruptions in user experience.
  • SEO-friendlyMake sure the link is clickable text, containing a meaningful title, which helps search engines understand the page structure.

ByprevArchiveandnextArchiveLabel, AnQiCMS users can easily build a smooth document navigation experience on the website.This not only simplifies template development, but also focuses on the user, enhancing the visibility of content and the overall activity of the website.


Frequently Asked Questions (FAQ)

Q1:prevArchiveandnextArchiveHow do you determine the previous/next document? Will they cross categories to search?A1:prevArchiveandnextArchiveTags are usually in the category of the current documentin the same categorySearch below.They determine adjacent documents based on the publication time or ID order of the documents.This means that if the previous or next document of the current document belongs to a different category, these tags will not be found and displayed by default.

Q2: If my website has multiple content models (such as articles and products), can these tags be used on all models?A2: Yes.prevArchiveandnextArchiveIs AnQiCMS universal document tags, as long as it is document content managed by AnQiCMS, whether it is an article model, product model, or custom model document, these two tags can be used on the detail page to display adjacent documents.

**

Related articles

How to generate breadcrumb navigation using the `breadcrumb` tag to enhance the user's understanding of the page hierarchy?

In complex website content structures, users sometimes feel lost, not knowing the position of the current page.At this time, an auxiliary navigation method called "Breadcrumb Navigation" is particularly important.It not only clearly displays the path from the home page to the current page, but also helps users quickly understand the hierarchical structure of the website, thereby improving the browsing experience.For websites built with AnQiCMS, the system-built `breadcrumb` tag is exactly the tool to generate this efficient navigation.

2025-11-07

How does the `contact` tag dynamically display website contact information (phone, address, email, etc.)?

AnQiCMS (AnQiCMS) provides a flexible and efficient way to manage various types of information on a website, where the dynamic display of website contact information can be easily realized through its built-in `contact` tag.This means you do not need to manually modify the code, and can manage phone numbers, addresses, email information centrally in the background, and have them automatically updated to various pages of the website. ### One, set the website contact information centrally in the background To dynamically display contact information, you first need to enter this information into the Anqi CMS backend.The operation path is very intuitive: log in to the background after

2025-11-07

How to build a multi-level navigation menu using the `navList` tag and display it on the front end?

AnqiCMS provides powerful and flexible configuration options for website navigation, allowing you to easily build multi-level navigation menus and customize the display on the front-end website according to business needs.Whether it is a simple single-layer menu or a complex multi-level navigation with dropdown content, the `navList` tag can help you a lot. To implement multi-level navigation, we first need to complete the configuration of the navigation structure in the background management system, which lays the foundation for the display on the front end.

2025-11-07

How to dynamically generate the page Title, Keywords, and Description using the `tdk` tag to optimize SEO display?

In website operations, Search Engine Optimization (SEO) is a key link to improve website visibility and attract natural traffic.Among them, the page's `Title` (title), `Keywords` (keywords), and `Description` (description), abbreviated as TDK, are important signals for search engines to understand the content of the page and determine the ranking.An excellent TDK setting can make your website stand out in a sea of information.AnQiCMS (AnQiCMS) fully understands the importance of TDK and has integrated powerful TDK management functions into the system design from the very beginning

2025-11-07

How does the `pagination` tag handle the pagination display logic for article lists and product lists?

How to efficiently display a large number of articles or products in a content management system without sacrificing user experience, this is often a challenge faced by website operators.AnQiCMS (AnQiCMS) provides powerful template tag features, among which the `pagination` tag is a powerful tool to solve this problem, allowing flexible handling of pagination logic for article lists and product lists, making your website content well-organized.

2025-11-07

How to manage and display document tags and associated document lists for `tagList` and `tagDataList` tags?

In content management, tags are an important bridge for connecting content, enhancing user experience, and optimizing search engine performance.AnQi CMS understands its importance, providing powerful tag management functions, and through the two core tags `tagList` and `tagDataList`, allowing content operators to flexibly display and manage document tags and their associated content. ### Tag: A Tool for Content Categorization and Discovery Tags in Anqi CMS are not just simple keywords; they are a refined way of organizing content.

2025-11-07

How filters (such as `truncatechars`, `safe`, `floatformat`) handle and format the data to be displayed?

In AnQi CMS template design, filters play a crucial role, as they are like the 'beautician' and 'processor' of data, able to process and format the original data to be displayed in the template, making it more beautiful and more in line with requirements for visitors.Understand and make good use of these filters, which can make your website content more flexible and professional.

2025-11-07

How can AnQi CMS efficiently display and manage content from multiple sites on a single interface?

## AnQi CMS: The Secret to Mastering Multi-site Content on a Single Interface In the digital wave, many enterprises or individuals often have more than one website to meet different business or content publishing needs, such as brand official websites, product display pages, sub-sites, marketing activity pages, or independent sites for users in different regions or languages.However, managing and operating the content of multiple websites often becomes a huge challenge due to its complexity, repetitive workload, and the difficulty of resource integration.How to achieve the centralized display and management of these scattered contents on a unified platform

2025-11-07