How to implement navigation between previous and next document sections using the `prevArchive` and `nextArchive` tags?

Calendar 👁️ 80

Ease your way: How to use Anqi CMSprevArchiveandnextArchiveTag to implement intelligent article navigation

As experienced website operators, we know that website content is not just about publishing, but how to let users browse smoothly in a vast amount of information and find the next article they are interested in is the key to improving user experience, extending stay time, and even optimizing SEO. In the powerful and flexible content management system AnQiCMS, ...prevArchiveandnextArchiveThese template tags are exactly the tools to achieve seamless navigation.

AnQi CMS, with its high-performance architecture based on the Go language and modular design, provides efficient and customizable content solutions for small and medium-sized enterprises and content operation teams.Its SEO-friendly features, as well as flexible template engine syntax, make it easy for content creators and developers to build outstanding websites.Today we will delve into the navigation of the previous and next documents, which is a microcosm of its excellent user experience design.

Why is the navigation between parts so important?

Imagine a user coming to an article on your website through a search engine.If this article has high-quality content, users are likely to be interested in reading related content.At this time, a prominent 'Previous' and 'Next' navigation, as if building a series of bridges across the content river for users.It can not only guide users to deeply browse the website, reduce the bounce rate, but also naturally increase the PV (Page View) of the page, form a good in-site link structure, which is of great benefit to the search engine's crawling and weight transmission.

For self-media operators, it can effectively improve the internal circulation efficiency of the content matrix; for corporate websites, it can help potential customers understand the details of products or services in an orderly manner, from introduction to application, to case studies, forming a complete cognitive path.

RevelationprevArchiveandnextArchiveTag

The AnQi CMS template system uses a syntax similar to the Django template engine, which is simple and powerful.prevArchiveandnextArchiveThe design of the label, which fully implements the concept of "user-centered": it's characterized by intelligence and simplicity:No parameters are requiredThese two tags can automatically identify the context of the current document and intelligently find the previous and next documents in the category or timeline it belongs to.

This means that when you use these tags on the document detail page, the system will automatically judge the relationship between the current document and provide the corresponding document data, greatly simplifying the complexity of template development.

Let's take a look at their basic usage:

{# 获取上一篇文档 #}
{% prevArchive prev %}
  {# 在这里编写上一篇文档的HTML结构 #}
{% endprevArchive %}

{# 获取下一篇文档 #}
{% nextArchive next %}
  {# 在这里编写下一篇文档的HTML结构 #}
{% endnextArchive %}

Between these two tag pairs, you can access the objects representing the previous or next document (in the example, they are the respective objects for the previous and next documents)prevandnext),and by the dot(.)to access various properties of these documents.

Learn more about the available data fields

prevandnextThe object provides rich document information, enough for us to build a beautiful and practical navigation link. The following are some common fields:

  • Id: The unique ID of the document.
  • Title: Document title. This is the most commonly used and most important display content.
  • Link: Document URL link. The address where users navigate when they click.
  • Description: The document's introduction or description. It can be displayed as supplementary information in navigation.
  • Thumb: The thumbnail address of the document. If the design allows, displaying a thumbnail can enhance visual appeal.
  • CategoryId: ID of document's category.
  • Views: Document's view count.

Combining these fields, we can easily build personalized navigation blocks. It is worth noting that not all documents have "Previous" or "Next" (for example, the first article in a category does not have "Previous", and the last article does not have "Next"), and we usually combine these tags when using them.ifConditional judgment to ensure that navigation is only displayed when data exists.

Practical case: Creating an elegant navigation block

Suppose we want to add a left and right column navigation block at the bottom of each article, with the left column being 'Previous article' and the right column being 'Next article'. If there are no more articles in one direction, it will display 'None' or 'Back to list'.

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

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

By such a code structure, we not only achieved the basic up and down navigation function, but also provided users with a richer and more friendly browsing experience through conditional judgment and flexible field invocation. When the mouse hovers over the navigation link, its title attribute (title) It can also provide more information, balancing accessibility and user-friendliness.

Summary

Of Security CMSprevArchiveandnextArchiveLabel, with its parameterless, automatically context-aware intelligent design, greatly simplifies the implementation of website article navigation.They not only help us build a smooth content flow experience, enhance users' stay time on the website and the efficiency of content discovery, but also lay a solid foundation for the website's SEO optimization.For any website operator who wants to provide an excellent user experience and efficient content management, mastering these two tags is undoubtedly an important part of the safe CMS content operation strategy.


Frequently Asked Questions (FAQ)

Q1: If a category has only one article, or the current article is the first/last article in the category,prevArchiveandnextArchiveHow will the tag perform?

A1: As mentioned in the article,prevArchiveandnextArchiveTags do not return any data when there is no corresponding document. Therefore, **it is always recommended to use{% if prev %}or{% if next %}This conditional judgment wraps the output of the navigation link. If the judgment is false (i.e., there is no previous or next article), you can choose to display a prompt text (such as "None") or provide a link back to the current category list page to guide the user to continue browsing.

Q2:prevArchiveandnextArchiveCan the tag implement cross-category navigation for previous and next articles? For example, if the current article belongs to Category A, but I want the 'next article' link to go to an article in Category B?

A2:prevArchiveandnextArchiveLabels are usually in the context of the current document(such as the same category, the same model)Look for the previous and next chapters. They are designed to provide navigation within a logically continuous content stream.If you need to implement cross-category navigation between previous and next articles, or define 'previous' and 'next' articles based on more complex logic (such as specific tags, publication time order instead of category order), you may need to combinearchiveListTags for more advanced customization development. This usually involves querying a list of documents under specific conditions, then manually calculating the target document ID and link based on the current document ID and sorting rules, which is more complex than directly using these two tags.

Q3: UseprevArchiveandnextArchiveWill the label affect the website performance?

A3: Will not. Anqí CMS is developed based on Go language, famous for its excellent high concurrency processing capability and lightweight features.prevArchiveandnextArchiveThe tag has been highly optimized at the bottom level, allowing for efficient querying and returning of data.Moreover, AnQi CMS supports various optimization measures such as static caching, further ensuring that the website can maintain extremely fast loading speed and response performance when handling these dynamic contents, with almost negligible impact on overall website performance.

Related articles

How to use the `archiveDetail` tag to get detailed information of a specific document?

As an experienced website operation expert, I know that content is the soul of the website, and how to efficiently and accurately present these contents is an indispensable part of our daily work.In such a powerful content management system as AnQiCMS, making good use of the template tags provided can greatly enhance our content operation efficiency.

2025-11-07

How to use the `archiveList` tag to get the document list in AnQiCMS template?

As an experienced website operations expert, and deeply familiar with AnQi CMS, I fully understand that how to efficiently obtain and display content is the core of building a website.Today, let's delve deeply into an extremely important and powerful tag in the Anqi CMS template, `archiveList`, which can help us flexibly obtain various document lists and provide endless possibilities for the presentation of website content.

2025-11-07

What are the functions of the 38 commonly used tags in AnQiCMS templates?

As an experienced website operations expert, I have a deep understanding of the powerful functions of AnQiCMS (AnQiCMS) and its flexible template system.It is not just a content management system, but also a tool that empowers enterprises and content operation teams, especially in terms of content display and management. Its core lies in a set of elegantly designed and feature-rich template tags system.Today, let's delve deeply into the 38 commonly used tags in the Anqi CMS template, see what roles they play, and how they help us easily build and manage all kinds of websites.

2025-11-07

What are the naming conventions for the document detail page and list page template files in AnQiCMS?

As a senior website operation expert, I am well aware that the naming rules of a content management system template are not only technical details, but also the foundation of content operation efficiency and website maintainability.AnQiCMS (AnQiCMS) is designed with flexibility and efficiency, and also provides clear and practical naming conventions in template management, allowing developers and operators to operate with ease.Today, let's delve into the naming rules of AnQiCMS's document detail page and list page template filenames to help you better master this powerful tool.

2025-11-07

How to get the specified model or sub-categories under the parent category of the `categoryList` tag?

## Taming AnQiCMS `categoryList` tag: How to efficiently obtain the specified model and subcategories under the parent category In the daily operation of AnQiCMS, content classification is the core of the website structure, which not only relates to the smoothness of the user's browsing experience but is also a key element that cannot be ignored in search engine optimization (SEO). In order to help everyone better manage and display website content, today we will delve into a very practical and powerful template tag in AnQiCMS——`categoryList`

2025-11-07

How to call the document's Tag list with `tagList` tag?

## The Powerful Assistant for Content Operation: The Clever Use of `tagList` Tag in AnQiCMS In the vast sea of the Internet, how to efficiently organize information, make it easy to find, and ultimately reach the target users accurately is a problem that every content operator is thinking about. AnQiCMS (AnQiCMS), as a content management system designed for enterprises and self-media, understands this pain point and provides powerful tools such as `tagList` in its powerful template tag system, helping us easily master content tags and add the charm of classification and aggregation to the website.

2025-11-07

How to implement pagination display for the document list with `pagination` tag?

As an experienced website operations expert, I know that an efficient content management system (CMS) is the cornerstone of website operations.AnQiCMS boasts a simple and efficient architecture with rich features, performing excellently in content publishing and management.Today, let's delve deeply into a seemingly simple but extremely important feature in AnQiCMS—the `pagination` tag, which elegantly implements pagination display of document lists to optimize user experience and enhance website performance.

2025-11-07

What specific features does the 'Content Management' module of AnQiCMS backend contain?

As an experienced website operations expert, I know that content is the soul of the website, and an efficient, flexible content management system (CMS) is the core engine that drives the lifecycle of website content.AnQiCMS (AnQi CMS) performs excellently in this regard, and its "Content Management" module is undoubtedly one of the most powerful and favored features by operators.

2025-11-07