How to call the previous and next document links in AnQiCMS template?

Calendar 👁️ 49

As an experienced CMS website operation person, I know the importance of content navigation for user experience and SEO.Today, with the website content becoming increasingly rich, how to guide users to smoothly browse related content is a key factor in improving user stickiness and reducing the bounce rate.Today, let's delve into how to cleverly call the links to the previous and next documents in the AnQiCMS template to optimize the structure of your website content and user path.

Enhance User Experience and SEO: Navigation of Previous and Next Documents in AnQiCMS Template

In a content management system, adding 'Previous' and 'Next' navigation for articles or product detail pages is a common and effective way to optimize user browsing experience.This can not only encourage visitors to stay longer on your website and discover more relevant content, but also help search engine spiders better understand the hierarchy and relevance of the website content, thereby improving the overall SEO performance of the website.AnQiCMS as an enterprise-level system focusing on efficient content management naturally also provides a concise and clear way to achieve this function.

Learn AnQiCMS Template and Tag Syntax

In AnQiCMS, the development of templates follows the syntax rules similar to the Django template engine. This means variables are enclosed in double curly braces{{变量}}Define, while control structures (such as conditional judgment, loop) use single curly braces and percent signs{% 标签 %}to mark. This clear syntax makes the writing and maintenance of templates relatively intuitive.

“Previous” and “Next” document links are usually placed on the detail page of a single document (such as an article detail page or a product detail page).AnQiCMS provides special template tags for this, which will automatically work in the context of the current document and intelligently find adjacent documents.

Call the link to the previous document

To display the link to the previous document of the current document, you can useprevArchiveThe tag is designed to be very concise, it does not require any parameters, and the system will automatically determine the previous document based on the sorting of the current document in the database (usually ID or publication time).

When you call in the template{% prevArchive prev %}...{% endprevArchive %}If there is a previous document, it will be assigned to the variable you define (for example, the one here,prevYou can visitprevVariableTitle(Document Title) andLinkProperties such as (document link) can be used to build your navigation elements.

The following is an example code snippet that calls the previous document link:

{% prevArchive prev %}
<div class="prev-document-navigation">
  {% if prev %}
    <a href="{{ prev.Link }}" title="{{ prev.Title }}">
      <span class="navigation-label">上一篇:</span>
      <span class="document-title">{{ prev.Title }}</span>
    </a>
  {% else %}
    <span class="no-document-indicator">已是第一篇</span>
  {% endif %}
</div>
{% endprevArchive %}

In this code, we first use{% prevArchive prev %}Label to get the data of the previous document and assign it toprevvariable. Then, through a{% if prev %}condition judgment to ensure that the link is displayed only when the previous document indeed exists. IfprevThe variable is empty (indicating that the current document is the first one), then display the prompt information "It is the first one".

In addition to the title and link, you can also call other available fields, such asThumb(thumbnail) orDescription(Description), to enrich your navigation display.

Invoke the link to the next document

Similar to the previous document, to display the link to the next document, you can usenextArchiveLabel. This label does not require any parameters; it will intelligently find the next document in the current document.

Using the template{% nextArchive next %}...{% endnextArchive %}If the next document exists, it will be assigned to the variable you define (such as the one here),next). You can also accessnextVariableTitle(Document Title) andLink(document link) and other properties.

This is an example code snippet for calling the next document link:

{% nextArchive next %}
<div class="next-document-navigation">
  {% if next %}
    <a href="{{ next.Link }}" title="{{ next.Title }}">
      <span class="navigation-label">下一篇:</span>
      <span class="document-title">{{ next.Title }}</span>
    </a>
  {% else %}
    <span class="no-document-indicator">已是最后一篇</span>
  {% endif %}
</div>
{% endnextArchive %}

The logic of this code is the same as calling the previous document link, just that theprevArchiveReplacenextArchive, and usenextA variable is used to carry the data of the next document. Similarly, a conditional judgment is also made before displaying the link to ensure the validity of the link.

Integrate the navigation of the previous and next documents.

In the document detail template, you usually place these navigation elements side by side, or arrange them according to design requirements.

An example of a complete document detail page navigation area may look like this:

<section class="document-navigation-area">
  {% prevArchive prev %}
  <div class="prev-document">
    {% if prev %}
      <a href="{{ prev.Link }}" title="上一篇:{{ prev.Title }}">
        <i class="icon-arrow-left"></i>
        <span>上一篇:</span>
        <span class="document-link-title">{{ prev.Title }}</span>
      </a>
    {% else %}
      <span class="disabled-link">无上一篇</span>
    {% endif %}
  </div>
  {% endprevArchive %}

  {% nextArchive next %}
  <div class="next-document">
    {% if next %}
      <a href="{{ next.Link }}" title="下一篇:{{ next.Title }}">
        <span>下一篇:</span>
        <span class="document-link-title">{{ next.Title }}</span>
        <i class="icon-arrow-right"></i>
      </a>
    {% else %}
      <span class="disabled-link">无下一篇</span>
    {% endif %}
  </div>
  {% endnextArchive %}
</section>

In this integrated example, we created independent containers for 'Previous' and 'Next', and added simple icons and text descriptions to enhance visual guidance.By flexibly applying CSS styles, you can design these navigation elements to match the overall style of your website.

Summary

Provided by AnQiCMSprevArchiveandnextArchiveLabels greatly simplify the implementation of navigation between documents. They are ready to use out of the box, and you can add efficient and user-friendly content navigation to your website with simple label calls and conditional judgments.Using these features correctly can not only enhance the user's browsing experience, but also indirectly promote the website's SEO performance, allowing the value of your content to be maximized.In your daily website operation, I strongly recommend that you fully utilize these powerful template functions to continuously optimize the way you display content.


Frequently Asked Questions (FAQ)

Why did I add previous/next tags to the document detail page, but they did not display any content?

In most cases, this may be due to several reasons: first, please make sure that you are currently accessing a valid document detail page, and not a list page or other types of pages.prevArchiveandnextArchiveThe tag is designed to automatically retrieve adjacent documents in the context of a specific document.Next, check if the current document is the first or last in its category, if so, there will be no previous or next document to display accordingly.Finally, please confirm that your template code includes{% if prev %}or{% if next %}Such condition judgment, to correctly handle the case where there are no adjacent documents.

What rules are used to sort and select the previous and next documents?

AnQiCMS'prevArchiveandnextArchiveLabels are usually determined according to the default sorting rules of the document (such as publication time or ascending/descending order of ID) to determine adjacent documents.In the context of the document details page, they will search for the previous and next documents in the same category as the current document, sorted according to the default sorting rules.This means they usually look for the closest document in the category of the current document, in chronological or ID order.

Can I use these tags on non-document detail pages (such as the homepage or list page)?

It is not recommended to use them directly on non-document detail pages (such as the homepage, category list page)prevArchiveandnextArchiveTags. These tags depend on the current page having a clear 'current document' context to work correctly.On the home page or list page, the system cannot determine which "current document" it is, so these tags will not be able to access the data.If you need to display related documents on these pages, you should usearchiveListtags, and cooperatecategoryIdortagIdFlexible content invocation with parameters.

Related articles

How to obtain document detail data and display content in AnQiCMS template?

As an experienced security CMS website operator, I know that it is crucial to efficiently and accurately obtain and present document detail data in terms of content display.A well-crafted detail page not only meets users' in-depth information needs, but also effectively enhances the website's stickiness and search engine performance through optimizing content structure and user experience.In Anqi CMS, taking advantage of its flexible Django template engine syntax, obtaining and displaying document detail data is a direct and powerful process.

2025-11-06

How to call the article or product category list in AnQiCMS template and implement multi-level nesting?

As a senior website operator at AnQiCMS, I fully understand that efficient content organization and presentation are crucial for user experience and SEO.Categorization list, especially multi-level nested categorization lists, can clearly present the hierarchical structure of the website's content, guide users to discover more interesting content, and also provide clear site structure information for search engines.This article will detail how to call the article or product category list in the AnQiCMS template and implement a multi-level nested display effect.

2025-11-06

How to get and display the navigation list and its sub-menu in AnQiCMS template?

## AnQiCMS Navigation List and Submenu Display in Templates As an experienced AnQiCMS website operations personnel, I am well aware of the importance of a clear and efficient website navigation for user experience and content access.AnQi CMS provides a powerful and flexible navigation list tag `navList` for template developers, making it easy to obtain and display the main navigation, footer navigation, and even more complex multi-level navigation structures with submenus on the website front-end.

2025-11-06

How to call the TDK (Title, Keywords, Description) information of the page in AnQiCMS template?

As a website operator who is well-versed in the operation of AnQiCMS, I deeply understand the importance of TDK (Title, Keywords, Description) information for the performance of the website in search engines and the willingness of users to click.AnQiCMS was designed with SEO-friendliness in mind from the beginning, providing us with flexible and powerful mechanisms to manage these key metadata.Properly calling TDK in the template is the basis for ensuring that website content is efficiently indexed, improves click-through rates, and enhances user experience.

2025-11-06

How to display the list of related documents in AnQiCMS template?

As a website operator who has been deeply involved in the CMS of security enterprises for many years, I know that effectively guiding users to discover more interesting content is crucial for enhancing user stickiness and the depth of website visits.Among them, the 'related document list' is undoubtedly one of the core functions to achieve this goal.It not only helps users conveniently explore more related topics, but also has a positive impact on the internal link structure of the website and SEO optimization.

2025-11-06

How to use the for loop in AnQiCMS template to traverse data and handle empty results with the empty tag?

## Master the data traversal and empty result handling in AnQiCMS templates: in-depth analysis of for loops and empty tags AnQiCMS, with its efficient and customizable features, has become the preferred content management system for many content operation teams and small and medium-sized enterprises.It is crucial for the flexibility of template language when building dynamic web pages.

2025-11-06

How to perform conditional judgments (if/elif/else) in Anqi CMS template?

As an experienced CMS website operation personnel, I am well aware that the flexibility of templates is crucial for efficient operation in daily content management.Especially conditional judgment allows us to intelligently control the display and hiding of content based on different data states and business logic, thereby providing users with a more accurate and personalized browsing experience.The Anqi CMS template engine has adopted the syntax style of Django, making the implementation of conditional judgments both powerful and easy to understand.### The basic structure of conditional judgment in AnQi CMS template Conditional judgment in the AnQi CMS template is mainly achieved through

2025-11-06

How to format timestamp output in AnQiCMS template?

As a professional familiar with Anqi CMS and proficient in content operation, I know that accuracy and beauty in website content display are crucial.A clear and easy-to-read timestamp that not only improves user experience but also reflects the standardization of data display.Below, I will give you a detailed introduction on how to format timestamp output in AnQiCMS template.

2025-11-06