How to get the previous, next article and related documents with AnQiCMS template tags?

Calendar 👁️ 47

As a senior CMS website operation personnel in the security industry, I am well aware of the importance of content in attracting and retaining users.Effective content management and a graceful user experience are the foundation of a successful website.In AnQiCMS, the flexible template tag system is the key to achieving this goal.Today, I will introduce to you in detail how to use the template tags of AnQiCMS to cleverly obtain the previous and next articles as well as related documents, thereby optimizing your content layout, enhancing user experience, and improving the SEO performance of the website.

Optimize user navigation: Get the previous document

On the article detail page, providing a link to the "previous" document is an important way to enhance the user's reading experience and page stay time.By guiding users to browse more content within the site, we can effectively reduce the bounce rate and provide the search engine with a richer internal link structure.

AnQiCMS provides intuitiveprevArchiveThe tag to get the previous content of the current document. This tag does not require any parameters, and it will intelligently retrieve the previous document that meets the conditions according to the publication time or ID of the current document.

You can use the following method to call the data of the previous document in your article detail template:

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

Here, prevThe variable will contain the details of the previous document, such asId(Document ID),Title(Title),Link(Link),Thumb(Thumbnail) etc. By a simpleifJudge, you can elegantly handle the case where there is no previous document, ensuring the friendly display of the page.

Guide the user to delve deeper: get the next document.

The link in the next document plays the role of bridging the previous and next documents.It encourages users to continue exploring your website, forming a coherent reading path.This continuity is not only beneficial to users, but also indicates to search engines that your website has rich and well-organized content.

In AnQiCMS,nextArchiveThe tag is a special tool for obtaining the next document. AndprevArchiveLike the tag, it also does not require additional parameters, and it will automatically locate the next content of the current document.

This is the template code example to get the next document.

{% nextArchive next %}
<div class="article-navigation next-article">
  {% if next %}
    <a href="{{ next.Link }}" title="{{ next.Title }}">
      <span class="nav-title">下一篇: {{ next.Title }}</span>
      <img src="{{ next.Thumb }}" alt="{{ next.Title }}" class="nav-thumb" />
    </a>
  {% else %}
    <span class="no-next-article">没有了,这已是最后一篇</span>
  {% endif %}
</div>
{% endnextArchive %}

nextThe variable will carry all the available fields of the next document, allowing you to flexibly display titles, links, thumbnails, and more information.Reasonably arrange these navigation elements, it will greatly enhance the user's browsing depth on your website.

Expand your reading horizon: get related documents.

The recommendation of relevant documents is an indispensable part of content marketing and user experience strategy.It can recommend more content that the user may be interested in based on the theme of the current article, effectively extending the user's session duration and guiding the user to discover the deep value of the website.

In AnQiCMS, obtaining related documents is not through an independent 'related documents' tag, but through flexiblearchiveListtags, combined with itstype="related"Parameters to implement. This design allows you to customize the retrieval logic of relevant documents according to different requirements.

The following is the template code and parameter description for retrieving relevant documents.

<div class="related-articles">
  <h3>相关推荐</h3>
  <ul>
    {% archiveList archives with type="related" limit="5" %}
      {% for item in archives %}
        <li>
          <a href="{{ item.Link }}" title="{{ item.Title }}">
            <img src="{{ item.Thumb }}" alt="{{ item.Title }}" class="related-thumb" />
            <span class="related-title">{{ item.Title }}</span>
          </a>
          <p class="related-description">{{ item.Description|truncatechars:80 }}</p>
        </li>
      {% empty %}
        <li>暂无相关文档。</li>
      {% endfor %}
    {% endarchiveList %}
  </ul>
</div>

archiveListTags are being used.type="related"At that time, it will automatically retrieve relevant content from the current document. You can further refine the matching logic of the relevant documents through the following parameters:

  • limit: Used to specify the number of relevant documents to display, for examplelimit="5"Will display 5 articles.
  • like: This parameter is the key to customizing the relevance matching rules.
    • When set tolike="keywords"When, the system will match relevant documents based on the keywords of the current document, recommending content similar to the keywords.
    • When set tolike="relation"When, the system will only display in the background document editing interface, the content you manually specify as 'related documents'.
    • If not specifiedlikeThe parameter, the system will default to trying to obtain the document closest to the current document in the same category as a related recommendation.

archivesHere is a document list array, you can iterate over it and access eachitemofId/Title/Link/Thumb/DescriptionThe fields are used to display relevant content. Reasonably using these parameters can build a highly personalized and accurate recommendation module for relevant content.

Summary and **practice**

By skillfully utilizing the AnQiCMS providedprevArchive/nextArchiveandarchiveList(type="related"These three types of template tags allow website operators to greatly enhance the user experience and content value of the site.These features provide solid technical support for your content strategy, whether it is to guide users in coherent reading or to expand their content discovery path.

In actual operation, I suggest that you always pay attention to the following points:

  • Consistency in designEnsure that the link styles of the previous, next, and related documents match the overall design style of your website, providing a smooth visual experience.
  • Information integrity: Besides the title and link, try to display thumbnails or brief descriptions to help users quickly determine whether to click.
  • Real-time feedbackUsing the AnQiCMS update mechanism, ensure that these navigation links always point to the latest and most accurate content.

By making these meticulous optimizations, you can not only keep users on your website longer, but also bring more exposure and conversion opportunities for your content.


Frequently Asked Questions (FAQ)

Q1: Why did I use in the article detail pageprevArchiveornextArchiveThe tag does not show the link to the previous or next document?

A1: There are usually several reasons for this. First, check if the current document contains a 'previous' or 'next' document that meets the criteria.This means that there must be other documents in the same category as the current document, and their publication time or ID must be before or after the current document.If the current document is the first or last in the category, the corresponding link will not be displayed.In addition, please make sure that all documents have been published, draft or unpublished documents will not be retrieved by these tags.

Q2: I want toarchiveListHow can I control the relevance of the "related documents" displayed in the tag?

A2: Of course.archiveListThe tag is intype="related"mode, it provideslikeParameters for defining the relevance of parameters. You can setlike="keywords", so that the system can automatically match similar documents based on the keywords of the current document; or setlike="relation"This will only display the documents you manually associated while editing documents in the background. If you have not set anylikeParameter, the system will default to recommending adjacent documents under the same category. Choose the one that best fits your content strategy.likeValue, it can significantly improve the accuracy of recommendations.

Q3: Are these navigation links (previous, next, related documents) displayed in a fixed style? Can I customize their appearance?

A3: AnQiCMS template tags are only responsible for providing data and do not interfere with the display style of the front end.This means you have complete freedom to customize the layout and appearance of these links through HTML and CSS.You can add custom HTML structure, CSS class names, and even use JavaScript to achieve richer interactive effects as needed, to perfectly integrate into your website design.

Related articles

How to obtain the current page's TDK information in AnQiCMS template and perform SEO optimization?

As an experienced website operator who deeply understands the operation of AnQiCMS, I have a very good understanding of the core value of TDK (Title, Description, Keywords) information for website search engine optimization (SEO).High-quality TDK is not only the key for search engines to understand the content of the page, but also the foundation for attracting users to click, improving website traffic and conversion rates.AnQiCMS as an enterprise-level content management system took full consideration of SEO requirements from the very beginning, providing a powerful and flexible TDK management and template calling mechanism.###

2025-11-06

How to implement flexible calls for document lists, category lists, and single page details with AnQiCMS template tags?

As a website operator who is deeply familiar with the operation of AnQiCMS, I know that content is the cornerstone of the website, and flexible and efficient content calls are the key to improving user experience and optimizing operational efficiency.AnQiCMS's powerful template tag system is the core tool we use to achieve this goal.It allows us to precisely control the display of document lists, category lists, and single-page details, thereby building website pages that are both beautiful and functional.

2025-11-06

How to use AnQiCMS template tags to get the system configuration information of the website (such as website name, Logo)?

As an experienced AnQi CMS website operation personnel, I am well aware of the importance of being able to flexibly call system configuration information when building and maintaining a high-efficiency, beautiful website.This information, such as the website name, logo, filing number, etc., is an indispensable part of the website's brand identity and basic operation.Strong and intuitive template tags provided by AnQi CMS allow you to easily obtain and display these system-level configuration information in website templates.

2025-11-06

How to troubleshoot and resolve issues when installing AnQiCMS, such as ports being occupied or insufficient database permissions?

As an experienced AnQiCMS (AnQiCMS) website operator, I know that a smooth system is the foundation for content creation and publication.AnQiCMS with its high efficiency and easy extensibility, brings great convenience to our content operation work.However, during the system deployment process, occasional setbacks may occur, the most common and annoying of which are the problems of 'port already in use' and 'insufficient database permissions'.Learn how to quickly identify and resolve them, it will ensure your AnQiCMS journey goes smoothly.###

2025-11-06

How to use conditional judgment (if) and loop traversal (for) tags for data rendering in AnQiCMS templates?

As an experienced Anqi CMS website operations personnel, I know that flexible content presentation is crucial for attracting and retaining users.AnQiCMS is a powerful template engine, especially its conditional judgment (`if`) and loop traversal (`for`) tags, which are the core tools for realizing dynamic content rendering.They allow websites to display information flexibly according to data status and business logic while maintaining consistency in content structure.

2025-11-06

How to implement quick multilingual switching of template content with translation tags in AnQiCMS?

As a senior AnQiCMS website operations personnel, I am well aware of the core status of content in website operations, especially under the wave of globalization, the rapid switching of multilingual content is crucial for user experience and market expansion.AnQiCMS provides a powerful and concise multilingual support mechanism, with its core being the flexible use of translation tags `{% tr %}` to quickly switch the multilingual content of templates.

2025-11-06

How to enhance the display of structured data on the page with AnQiCMS's Json-LD custom call tag?

As an experienced CMS website operation person in the digital world, I know the power of content.High-quality content is the foundation for attracting and retaining users, and how to make these contents better understood and displayed by search engines is one of the core issues for our operation staff.Today, I want to delve deeply into the Anqi CMS Json-LD custom call tag, and how it has become a powerful tool for us to enhance the display of structured data on web pages.

2025-11-06

What specific SEO elements does the "Home TDK" in AnQiCMS refer to?

As an experienced website operator, I know that Search Engine Optimization (SEO) is the key to the success of a website, and the setting of the TDK (Title, Description, Keywords) on the homepage is the foundation for our SEO work.AnQiCMS is a system focused on efficient content management, which fully considers SEO requirements from the beginning of its design, providing us with a simple and powerful TDK configuration function.I will elaborate in detail on the specific SEO elements and their operational significance referred to by the home page TDK in AnQiCMS

2025-11-06