How to implement the links and title display of the previous and next document pages on the content detail page?

Calendar 👁️ 79

In website operation, the navigation function of the previous and next pages on the content detail page seems minor, but it has a significant impact on user experience and the SEO performance of the website.It not only guides users to continue browsing more related content, improving the depth and duration of page visits, but also provides a clear page flow for search engine spiders to help the inclusion and ranking of website content.For partners using AnQiCMS to manage content, implementing this feature is very direct and efficient.

AnQi CMS, with its concise and efficient architecture and support for Django template engine syntax, makes template customization very friendly.Add previous and next article links and titles on the content detail page, which can be easily achieved through built-in template tags.

Anqi CMS overview of the previous and next document function

The AnQi CMS provides two special template tags for content detail pages, namelyprevArchiveused to get the previous document, as well asnextArchiveUsed to get the next document. The cleverness of these tags lies in the fact that they do not require manual specification of the current document ID or category. The system will automatically identify the document on the current detail page and intelligently find the adjacent previous and next documents.

These tags can conveniently obtain various information about adjacent documents, such as:

  • Id: The unique ID of the document
  • Title: Document title
  • Link: The access link of the document
  • Thumb: The thumbnail of the document (if available)

With this information, we can build user-friendly and informative navigation links.

Detailed steps of implementation

To implement the previous and next navigation on the content detail page of your Anqi CMS website, it usually only requires modifying the corresponding template file of the content detail page.

Step 1: Locate the content detail page template

According to the template making conventions of Anqi CMS, the template file for the content detail page is usually located under the current theme you are using{模型table}/detail.htmlFor example, if it is an article model, that might bearticle/detail.htmlIf you have a custom detail page template, please find the file you are using.

Step two: Insert previous and next navigation tags

In the detail page template file found, you can add the following code block at the bottom of the document content area or at any appropriate position to display the links and titles of the previous and next documents.

<nav class="article-navigation">
    <div class="prev-article">
        {% prevArchive prev %}
            {% if prev %}
                <a href="{{prev.Link}}" title="{{prev.Title}}">
                    <span>&laquo; 上一篇</span>
                    <h3>{{prev.Title}}</h3>
                </a>
            {% else %}
                <span class="no-article">已经是第一篇了</span>
            {% endif %}
        {% endprevArchive %}
    </div>
    <div class="next-article">
        {% nextArchive next %}
            {% if next %}
                <a href="{{next.Link}}" title="{{next.Title}}">
                    <span>下一篇 &raquo;</span>
                    <h3>{{next.Title}}</h3>
                </a>
            {% else %}
                <span class="no-article">已经是最后一篇了</span>
            {% endif %}
        {% endnextArchive %}
    </div>
</nav>

This code will call separatelyprevArchiveandnextArchivetags, and store the information of the previous document obtained inprevvariables, and the information of the next document innextthe variable.

Code example analysis:

  • {% prevArchive prev %}and{% nextArchive next %}This is the syntax for calling the built-in tags of Anqie CMS.prevandnextThis is the variable name we define for adjacent document data, you can name it freely.
  • {% if prev %}and{% if next %}These two condition judgments are very important. They checkprevornextDoes the variable have actual content. If the current article is the first one in the category, thenprevit will be empty; if it is the last one,nextWill be empty. Through this judgment, we can elegantly display such prompts as 'It is the first/last article' instead of displaying an empty link.
  • <a href="{{prev.Link}}" title="{{prev.Title}}">: Used here<a>Create a hyperlink with the label.{{prev.Link}}It will output the URL of the previous document,{{prev.Title}}and as the link of its title,titleattribute, enhancing SEO and user experience.
  • <h3>{{prev.Title}}</h3>: Display the title of the previous document as visible text. You can choose to useh3/por other tags.
  • <span class="no-article">已经是第一篇了</span>When there is no previous or next document, this prompt text will be displayed. You can adjust its content and style according to your website style.
  • &laquo;and&raquo;These are HTML entity characters representing double left arrow and double right arrow, commonly used to indicate the previous/next page visual effect.

Advanced Optimization and Precautions

  1. Style BeautificationThe above code only provides the structure, the specific visual effects need to be beautified through CSS. You canarticle-navigation/prev-article/next-article/no-articleAdd appropriate CSS styles to the class to keep it consistent with your website design, such as setting float, width, font color, margin, etc.

  2. Contextual association: AnQi CMS'sprevArchiveandnextArchiveTags are very intelligent, they will automatically match based on the current document ID and publish time, inthe category or modelLooking for adjacent documents. This means that if your article belongs to the "Technology Articles" category, it will only find the previous or next article within the "Technology Articles" category, and will not jump to the documents in the "Product Introduction" category.This contextual relevance is very beneficial for maintaining the logic of the user's browsing path.

  3. Multi-model support: Regardless of the content you are using, whether it is an article, product, or other custom modelarchiveThe detail page template is used to display, this method is applicable. The strength of Anqi CMS lies in its flexible content model, which makes it easy to apply these general functions to various types of content.

By following these steps, you can implement a fully functional, user-friendly previous and next document navigation feature on the content detail page of Anqi CMS.This not only improved the professionalism of the website, but also effectively promoted in-depth content reading and SEO optimization.


Frequently Asked Questions (FAQ)

Q1: If my article does not have a previous or next article, how will the navigation links display?

A1: As shown in the example code, we used{% if prev %}and{% if next %}such conditional judgment. If the current article does not have a previous one,prevthe variable will be empty, and the system will display where you are{% else %}Text defined within the block, for example, 'It is the first article already.'Similarly, if there is no next one, it will show 'This is the last one'.This ensures that the display of the navigation area always remains elegant and clear.

Q2: What is the order of the previous/next link?

A2: The previous/next feature of AnQi CMS usually sorts documents based on the publication time (CreatedTime) or document ID (Id) to find adjacent documents.Generally, documents released later or with larger IDs are considered as 'next', whereas the opposite is 'previous'.This default logic ensures the natural flow of content, in line with reading habits.

Q3: Can I customize the document information displayed in the previous or next navigation? For example, besides the title, I also want to display a thumbnail.

A3: Of course, you can.prevandnextThe variable contains various information from adjacent documents, such asId/Title/Link/Thumbetc. You just need to{% if prev %}or{% if next %}in the code block, and you can reference these variables as needed. For example, to display a thumbnail, you can<a>in the tag.<img src="{{prev.Thumb}}" alt="{{prev.Title}}">. Please adjust your template design flexibly according to the available field information.

Related articles

How to display the document Tag label on the front-end page and use it as an entry for content association?

In modern website operations, how to effectively organize and present content is not only related to user experience, but also a key aspect of Search Engine Optimization (SEO).AnQiCMS (AnQiCMS) provides a powerful and flexible Tag label feature, which not only helps you better manage website content but also serves as a convenient entry point for users to find related information, greatly enhancing the association of content and the interactivity of the website. ### Overview of Tag Labels in AnQi CMS The design philosophy of Tag labels in AnQi CMS is very open and flexible.They are different from the traditional classification system

2025-11-09

How to set a default thumbnail to ensure that documents without uploaded images also have a unified display?

When using AnQi CMS to manage website content, we often encounter such situations: some articles, products, or pages may not have uploaded exclusive thumbnails due to insufficient content or oversight.This not only makes the website page look unprofessional and inconsistent, but may also affect users' desire to click on the content.Luckyly, Anqi CMS provides a very practical feature that can solve this problem once and for all - that is, setting a default thumbnail to ensure that even documents that do not upload pictures separately can have a unified and beautiful display effect.Why is it necessary to set a default thumbnail

2025-11-09

How different thumbnail processing methods (aspect ratio scaling, padding, cropping) affect the display effect of images on the front-end?

In website operation, images play a vital role, especially in places like list pages and detail pages where thumbnails are displayed. They not only affect the beauty of the page but also directly relate to the click-through rate and reading experience of users.AnQiCMS (AnQiCMS) offers various flexible thumbnail processing methods to help users meet the needs of image display in different scenarios.Understanding how these methods - scaling, padding, and cropping - affect the final presentation of images on the front end is particularly important for optimizing the visual experience of a website.Why is thumbnail processing so crucial

2025-11-09

How to optimize front-end loading and display by converting and automatically compressing images within the site to Webp format?

Optimize the website front-end loading and display, images are one of the key links.For us who pursue efficiency and a good user experience, it is crucial to properly handle the images on the site.The AnQiCMS (AnQiCMS) provides very practical functions in this aspect, through WebP format conversion and automatic compression, we can significantly improve the loading speed and image display effect of the website.We all know that large image files are a common cause of slow website loading.This will not only affect the user experience and increase the bounce rate, but also have a negative impact on search engine optimization (SEO)

2025-11-09

How to retrieve and display a list of related documents based on the current document to enhance content relevance?

How to keep visitors immersed in your site after they have finished reading an exciting article and discover more interesting information?One of the answers is to intelligently display relevant documents. This can effectively enhance user experience, extend the time users spend on the website, and for search engine optimization (SEO), it can also help spiders better crawl and understand the website structure through the construction of internal links, thereby improving the relevance of the content and the overall weight of the website.In Anqi CMS, it is not a complex thing to get and display the list of related documents

2025-11-09

How to flexibly call and display custom fields in front-end templates?

When using AnQi CMS to manage website content, its powerful content model and custom field features provide great flexibility for the personalized needs of the website.At times, we not only need to publish regular article titles, content, etc., but also need to add some unique information for specific types of articles or products, such as the author of the article, product model, launch date, and special selling points.This information is implemented through the content model custom fields.How can I flexibly call and display these custom fields in a website front-end template?This is the issue we are going to delve into today.

2025-11-09

How to use the `archiveFilters` tag to implement dynamic display of a multi-condition filter list?

How can we make it quick for users to find the information they need on the website, which is a key factor in improving user experience and conversion rate.When a website contains a variety of content, and each type of content has multiple attributes to choose from, providing a flexible multi-condition filtering function becomes particularly important.AnQiCMS provides a powerful `archiveFilters` tag that can help us easily implement dynamic filtering of content lists, making your website content come to life.Why do we need multi-condition filtering? Imagine that you are browsing a real estate website

2025-11-09

How does Anqi CMS implement highly customized display of the website front-end page?

How to implement high-level custom display of the website front-end page in AnqiCMS? Want to create a unique and powerful website? The key is to have a flexible grasp of the front-end page.AnqiCMS fully understands this, it not only provides an efficient and stable background management, but also endows users with extremely high customization capabilities on the front end.This is due to its exquisite template design, flexible content organization, and rich tag system, allowing users to build and present websites according to their own imagination.### One, Flexible Template System

2025-11-09