How to implement 'Previous' and 'Next' document navigation on the AnQiCMS article detail page?

Calendar 👁️ 80

In Anqi CMS, implementing the 'Previous' and 'Next' navigation function on the article detail page is a key link in improving user experience and guiding users to delve deeper into the website's content. It also helps optimize the internal link structure of the website and is very beneficial for SEO performance.AnQiCMS has a powerful template system and flexible tag functions, making this operation intuitive and efficient.

How to implement 'Previous' and 'Next' document navigation in AnQiCMS

AnQiCMS has designed a series of convenient template tags, specially used for obtaining information about adjacent documents in article detail pages. Among them,prevArchiveandnextArchiveThese tags are the core tools for implementing 'previous article' and 'next article' navigation.They can intelligently judge the position of the current article in the category it belongs to or in the entire model, and automatically extract the titles and links of adjacent articles, making it convenient for us to display them in the front-end template.

the usage analysis of the core tags

Let's understand the specific use and common fields of these two tags:

prevArchiveTag: Get the previous document

This tag is used to get the details of the previous article of the current article.

  • Function:In the article detail page, display a link to the previous related article.
  • Example of usage:
    
    {% prevArchive prev %}
    {% if prev %}
      <a href="{{ prev.Link }}">{{ prev.Title }}</a>
    {% else %}
      <span>没有了</span>
    {% endif %}
    {% endprevArchive %}
    
    In the above code,prevArchiveThe tag will assign the data of the previous article toprevthe variable. We use{% if prev %}To determine if the previous article exists. If it exists, it can be accessed through{{ prev.Link }}Retrieve article link through{{ prev.Title }}Get the article title.
  • Fields that can be obtained: prevThe variable provides multiple fields that can be flexibly called according to the need, for example:
    • Id: Article ID
    • Title: Article title
    • Link: Article link
    • Description: Article Summary
    • Thumb: Article Thumbnail
    • CreatedTime:Publish time, etc.

nextArchiveLabel: Get the next document

This label is similar toprevArchiveIt is used to get the details of the next article of the current article.

  • Function:In the article detail page, display a link to the next related article.
  • Example of usage:
    
    {% nextArchive next %}
    {% if next %}
      <a href="{{ next.Link }}">{{ next.Title }}</a>
    {% else %}
      <span>没有了</span>
    {% endif %}
    {% endnextArchive %}
    
    here,nextArchiveThe tag assigns the data of the next article tonexta variable. Similarly, use conditional judgment to handle whether there is a next article.
  • Fields that can be obtained: nextVariable fields available withprevVariables are essentially consistent, includingId/Title/Link/Description/Thumb/CreatedTimeetc.

Integrate navigation in the template: practical examples

Generally, we will be in the AnQiCMS article detail page template file (such as{模型table}/detail.html)Add these navigation codes. Below is a more complete code example showing how to merge 'Previous' and 'Next' navigation, including considerations for thumbnail display and style control:

<div class="article-pagination">
    <div class="prev-article-nav">
        {% prevArchive prev %}
        {% if prev %}
            <a href="{{ prev.Link }}">
                <span class="nav-direction">← 上一篇</span>
                {% if prev.Thumb %}
                    <img src="{{ prev.Thumb }}" alt="{{ prev.Title }}" class="nav-thumb">
                {% endif %}
                <h4 class="nav-title">{{ prev.Title }}</h4>
            </a>
        {% else %}
            <span class="nav-direction">← 上一篇</span>
            <h4 class="nav-title">没有了</h4>
        {% endif %}
        {% endprevArchive %}
    </div>

    <div class="next-article-nav">
        {% nextArchive next %}
        {% if next %}
            <a href="{{ next.Link }}">
                <span class="nav-direction">下一篇 →</span>
                {% if next.Thumb %}
                    <img src="{{ next.Thumb }}" alt="{{ next.Title }}" class="nav-thumb">
                {% endif %}
                <h4 class="nav-title">{{ next.Title }}</h4>
            </a>
        {% else %}
            <span class="nav-direction">下一篇 →</span>
            <h4 class="nav-title">没有了</h4>
        {% endif %}
        {% endnextArchive %}
    </div>
</div>

By this code, we not only achieved basic text navigation, but also added thumbnail display, which can greatly enhance the user's visual experience.Of course, you also need to add the corresponding CSS styles to beautify these navigation elements according to your website design.

Optimize user experience and content operation considerations

Implement the "Previous" and "Next" navigation of articles, not just a simple addition of features, but also contains important content operation strategies:

  1. Enhance user stickiness:A smooth reading experience makes users more willing to stay on the website, continue browsing along related content, thereby extending the visit time and reducing the bounce rate.
  2. Optimize internal link structure:Each "Previous" and "Next" link is a high-quality internal link, which helps search engines better crawl and understand the content structure of the website, and has a positive effect on the inclusion and ranking of articles.
  3. Content flow automation:For websites that are updated frequently, such as news sites, blogs, or product update pages, this automatic navigation ensures that users can always find the latest or oldest related content without manually searching.

These tag features of AnQiCMS are exactly to enable content operators to easily build a feature-rich, user-friendly website, so that they can focus more on creating and spreading high-quality content.

Frequently Asked Questions (FAQ)

1. Why does my 'Previous' or 'Next' link show 'None'?

This usually means that the current article is already the first one in its category or the entire content model (for "previous" it means the first one, and for "next" it means the last one).AnQiCMS will determine the adjacent relationship of articles based on the publication time (or ID sequence, depending on the system default configuration).If the current article does not have any earlier or later articles, it will display "none."

2. How is the order of the 'Previous' and 'Next' navigation determined?

AnQiCMS usually determines the publication time of articles based on (CreatedTimeSort by time proximity first, showing the documents closer in time.If there is no explicit publication time, it may revert to the order based on the article ID.This means that the latest published articles may appear adjacent in the navigation, making it convenient for users to track updates.

3. Can I customize the content displayed for "Previous" and "Next" articles? For example, besides the title, can I also display a summary or thumbnail?

Of course you can.prevandnextVariables provide rich fields such as article title(Title), Link(Link), thumbnail(Thumb), even the article summary(Description) etc. You can freely combine these fields in the template according to your design needs, such as displaying an article thumbnail next to the title, or showing a brief introduction when hovering, to enhance the visual appeal and information content of navigation.

Related articles

How to display hot articles on the AnQiCMS homepage based on article views?

On AnQiCMS, the homepage is usually the important entry point for visitors to understand the website content and quickly obtain information.Effectively display popular articles, not only to attract users' attention, improve content exposure, but also effectively enhance the user experience of the website and PV (page views).AnQiCMS with its flexible template tags and built-in features makes this operation very simple and intuitive.

2025-11-08

How to display article thumbnails in the Anqi CMS article list?

## How to Display Thumbnails Gracefully in AnQi CMS Article List Visual appeal of the article list page is crucial in website operation.A carefully selected or automatically generated thumbnail that can quickly catch the visitor's attention, convey the theme of the article, and thus improve click-through rate and optimize user experience.Our AnQi CMS provides flexible and powerful functions, helping us easily display article thumbnails in the article list.

2025-11-08

How to call and display custom parameter fields of articles in the Anqi CMS template?

In AnQi CMS, the custom parameter field of the article is an important manifestation of its core feature of 'flexible content model'.It allows us to define unique additional attributes for different types of content (such as articles, products), greatly enhancing the expressiveness of content and the customization capabilities of the website.Imagine if your website needs to display product details, in addition to the general information such as title, content, and images, you may also need specific parameters such as 'model number', 'color', 'storage capacity', and so on.These are the places where custom parameter fields take effect.

2025-11-08

How to customize the title display format of AnQi CMS article detail page?

The secret to flexibly customizing the CMS article detail page title display formatIt not only affects the identification of users in browser tabs and favorites, but is also one of the key elements of search engine optimization (SEO).A clear, attractive, and well-formatted title that can effectively improve the click-through rate of the article and the professional image of the website.

2025-11-08

How to configure the lazy loading effect of images in the AnQiCMS article content?

In AnQiCMS, optimizing website loading speed is a key step to improving user experience and search engine rankings.When the article content contains a large number of images, these images will significantly increase the page loading time.Image lazy loading (Lazy Loading) is an efficient way to solve this problem, it can prevent images from loading until they enter the user's field of vision, thereby speeding up the initial rendering speed of the page.AnQiCMS as a content management system focusing on performance and SEO provides flexible support for lazy loading images in article content.You can configure the template simply

2025-11-08

How to correctly render Markdown formatted article content in AnQi CMS and display it?

Today, with the increasing efficiency in content creation, Markdown is favored by content creators for its concise syntax and focus on the content itself.AnQi CMS understands this trend and provides powerful features that allow you to easily convert Markdown-formatted article content into exquisite HTML pages and support richer display effects, such as mathematical formulas and flowcharts.

2025-11-08

How to display the associated Tag tag list on the AnQiCMS article detail page?

In website content operation, tags are important tools for connecting related content, enhancing user experience, and optimizing search engine rankings.AnQiCMS as an efficient content management system, naturally supports the association function between articles and tags.How can we clearly display these associated tags on each article's detail page to allow readers to quickly find more interesting content?This article will guide you in easily displaying the tag list on the article detail page of AnQiCMS.

2025-11-08

How to implement website in-site search and display article search results in AnQiCMS?

In website operation, the in-site search function plays a crucial role.It can not only help visitors find the information they need quickly, improve user experience, but also through the analysis of search data to understand user needs, optimize content strategy.The AnQi CMS is an efficient content management system that provides a set of intuitive and powerful mechanisms to implement site search and flexibly display search results.The on-site search function of Anqi CMS is designed to be very practical.

2025-11-08