How to display the links and titles of the previous and next documents in AnQi CMS?

Calendar 👁️ 68

How to easily display the link and title of the previous and next document in AnQi CMS?

When browsing website articles, we often hope to smoothly jump from the current content to the previous or next related article. This seamless reading experience not only enhances user satisfaction but also has a positive effect on the overall content structure and SEO optimization of the website.AnQi CMS is well-versed in this, providing content operators with an extremely convenient way to deploy such navigation functions with its flexible and powerful template engine.

Intelligent Navigation: Tags of the previous and next document

In the Anqi CMS template system, to implement the display of the previous and next documents, it mainly depends on two core tags:prevArchiveandnextArchive.These tags are specifically designed for document detail pages, capable of intelligently recognizing the current document and automatically finding adjacent documents in the same category or time series.They not only return the full link of the previous or next document but also provide key information such as document titles, allowing developers to easily build intuitive navigation elements on the page.

Actual operation: how to call in the template

AnQi CMS adopts a template syntax similar to Django, by{% 标签名 %}to handle logic,{{ 变量名 }}to output content. Suppose we are editing the detail page template of a document (usuallydetail.htmlOr a custom document template), you can call the information of the previous and next documents like this:

We first use{% prevArchive prev %}Tag to try to get the previous document and assign it toprevthe variable. Then, through{% if prev %}Make a judgment, ifprevThe variable has a value (i.e., there is a previous document), then build a<a>link, through{{ prev.Link }}Output the link address, through{{ prev.Title }}Output the document title. IfprevIf there is no value, it will display the prompt 'There is no previous one'. The calling method of the next document is similar, usingnextArchiveTags andnextvariables only.

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

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

With this concise code, the website can have basic article navigation functions. You can adjust it as needed<span>Text inside labels, or add additional CSS styles to links, so that they maintain consistency with the overall design style of the website.

A richer navigation display

In addition to basic links and titles,prevArchiveandnextArchivetags can also provide more detailed document information, such as document thumbnails (Thumb), brief description (Description) etc. This allows us to create more attractive graphic navigation, thereby enhancing the user experience.

For example, if you want to display thumbnails in the next navigation at the same time, you can expand it like this:

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

With these flexible field combinations, you can customize various forms of document navigation according to the website design style, whether it is a simple text link, or a card-like navigation with a preview image and a brief description, AnQi CMS can easily handle it, making your content display more attractive.

Summary

In summary, Anqi CMS passesprevArchiveandnextArchiveThese two concise and powerful template tags greatly simplify the implementation process of website document navigation.This not only improves the user browsing experience, promotes the internal flow of website content, but also helps search engines better understand and capture the structure of the website, providing strong support for SEO optimization.For content operators who pursue efficiency and flexibility, mastering the use of these tags will undoubtedly make your website content more vibrant.


Frequently Asked Questions (FAQ)

1.prevArchiveandnextArchiveDoes the tag support use on the article list page?These tags are specifically designed for the document detail page.They need a "current document" as a reference point to find the previous or next one.On the article list page, since there is no clear 'current document', these tags cannot take effect directly.

2. If the document does not have a previous or next article, will the page report an error?Can't. As shown in the example in the article, you can use{% if prev %}or{% if next %}Such a conditional judgment is used to check for the existence of the previous or next document.If not available, you can choose to display prompts such as 'No previous article' or 'No next article' instead of causing the page to error.

3. What information can you get besides the title and link to beautify the navigation of the previous/next article?exceptTitleandLink, you can also use{{ prev.Thumb }}(thumbnail),{{ prev.Description }}(brief description),{{ prev.CreatedTime }}(Publish time) and other fields to get more information. This information can help you build richer, more visually appealing navigation elements, such as navigation cards with image previews.

Related articles

How to display filter conditions on the document list page of Anqi CMS and dynamically update results based on parameters?

In AnQi CMS, adding filtering conditions to the document list page and dynamically updating the results based on user selection is an important aspect of improving the discoverability and user experience of website content.This not only helps visitors quickly locate the content they are interested in, but also has a positive impact on SEO through a clear URL structure.Let's understand step by step how to implement this feature in Anqi CMS. ### Core Function: Content Model and Custom Fields are Basic Everything in Anqi CMS is built based on the "Content Model". The filtering function on the document list page

2025-11-09

How to display dynamic breadcrumb navigation and customize its display in Anqi CMS?

When we browse websites, we often see a line at the top or bottom of the page indicating the current navigation path, which is what we usually call 'Breadcrumbs'.It can not only clearly tell the user the position of the current page in the website structure, but also effectively improve the user experience and search engine optimization (SEO) effect of the website.AnQiCMS (AnQiCMS) is a powerful content management system that comes with a convenient way to generate and customize this dynamic breadcrumb navigation.

2025-11-09

How to implement flexible navigation menu and submenu display in AnQi CMS template?

In website operation, a clear and intuitive navigation menu is the core of user experience.It can not only help visitors quickly find the information they need, but it is also a direct embodiment of the structure and content organization logic of the website.AnQiCMS (AnQiCMS) leverages its efficient architecture based on the Go language and Django-style template engine to provide great flexibility for content creators and developers, enabling the display of various complex navigation menus and sub-menus.Implement flexible navigation menus and sub-menus in the AnQi CMS template

2025-11-09

How to set the SEO display rules for article, product, page titles and other content in AnQi CMS?

In website operation, the content title is like the facade of the website, it is not only the first impression seen by visitors, but also an important basis for search engines to understand the content of the page and judge its relevance.A meticulously optimized content title that can significantly improve the click-through rate (CTR) and ranking of the website.AnQiCMS (AnQiCMS) as a highly SEO-friendly content management system, has provided us with very flexible and powerful tools to finely set the SEO display rules for articles, products, pages, and other content. Next

2025-11-09

How to display related recommended documents on the document detail page of AnQi CMS and customize the recommendation logic?

After visitors have read an interesting document or viewed a product introduction on your website, if they can get more relevant recommendations in a timely manner, it will undoubtedly greatly enhance their visit experience, extend their stay time, and encourage them to explore more corners of the website.AnQi CMS knows this and provides flexible and diverse features to help you cleverly display related recommendations on the document detail page, and can customize the recommendation logic according to your operational strategy. We will delve into how to implement this feature in Anqi CMS in detail.###

2025-11-09

How to use Anqi CMS tags and filters to format date and timestamp display?

The timeliness and readability of website content largely depend on the accuracy and aesthetics of date and time information.AnQi CMS as an efficient content management system provides flexible tags and filters, helping us easily implement personalized display of dates and timestamps, making your website content more in line with user habits and enhancing the overall reading experience.This article will deeply explore how to巧妙运用these functions in Anqi CMS, converting raw time data into a clear and understandable display form.### Understand the Date and Time Data in Anqi CMS In Anqi CMS

2025-11-09

How to display the friend link list in Anqi CMS and distinguish the rel="nofollow" attribute?

Friendship links play an important role in website operation, they not only help to increase the number of external links on the website, but also have a positive impact on search engine optimization (SEO), and can also provide users with more related resource entries.However, not all friendship links are suitable for passing weight or obtaining search engines' 'recommendations', at this point the `rel="nofollow"` attribute is particularly important.AnQiCMS (AnQiCMS) is a powerful content management system that fully considers the needs of website operators and provides a convenient link management function

2025-11-09

How to configure and display the site name, Logo, and filing information for Anqi CMS website?

The identity of a website often starts with its site name, logo, and filing information.In AnqiCMS, configuring and displaying these core information is the first step in building a website and is also a crucial step.The entire process is intuitive and convenient, even if you are a beginner using AnqiCMS, you can easily complete it.Next, we will introduce how to complete these settings in AnqiCMS and display them on your website.--- ### **First Step: Configure the website's basic information** First

2025-11-09