How to display a list of recommended documents related to the current document on the document detail page?

Calendar 👁️ 71

In website content operation, providing users with relevant recommended content can not only effectively improve the depth and stay time of page browsing, but also optimize the user experience and indirectly help improve the SEO performance.In AnQiCMS (AnQi Content Management System), implementing this feature is both flexible and direct.Next, we will discuss how to seamlessly integrate and display the recommended document list closely related to the current document on the document detail page.

Core value: Why should recommended documents be displayed on the document detail page?

Imagine when a user finishes reading an interesting article, if there is no guidance, they are likely to leave the website.And a carefully planned list of recommended documents, as if it opens more doors for exploration.This can not only make users stay longer on your website and discover more valuable content, but also means higher page views, lower bounce rates, and page weight enhancement through internal links, all of which are positive signals that search engines welcome.

Understand how AnQiCMS defines “related”

In AnQiCMS, the definition of “related documents” is multi-dimensional, you can choose flexibly according to your actual needs:

  1. Based on content similarity (default intelligent recommendation):The intelligent mechanism built into AnQiCMS will automatically match and recommend documents with higher relevance based on the current document's classification, keywords, and even the similarity of the content text.This is the most commonly used and convenient way.
  2. Based on category association:Documents in the same category naturally have certain relevance.
  3. Based on tag association:Documents with the same label, even if they belong to different categories, can establish strong associations through the label.
  4. Manually specify the association:When editing documents in the AnQiCMS background, you can also manually specify some specific related documents for the current document to achieve more accurate editing control.

Prepare the work for implementing the recommendation list on the document detail page

Before starting to add code, make sure you understand the template structure of AnQiCMS. Usually, the template file corresponding to the document detail page is stored in a similar{模型table}/detail.htmlpath, for examplearticle/detail.htmlorproduct/detail.html. You need to edit these files.

In addition, to make the recommendation mechanism more effective, your document content should already be reasonably set with categories, keywords, and tags, which are the basis for AnQiCMS intelligent matching.

Core implementation: utilizingarchiveListDisplay recommended documents

AnQiCMS provides powerfularchiveListtags, we can cleverly utilize itstype="related"parameters to automatically obtain relevant documents.

In your document detail page template (such asarticle/detail.htmlIn the text, find the location where you want to display the recommended document list, which is usually below or in the sidebar of the article. Then, you can insert the following code snippet:

{# 推荐文档列表区域开始 #}
<div class="related-articles">
    <h3>您可能也喜欢:</h3>
    <ul>
        {# 使用 archiveList 标签获取相关文档。type="related" 是关键,它会智能匹配。 #}
        {# limit="5" 表示我们希望显示最多5篇推荐文章。 #}
        {% archiveList archives with type="related" limit="5" %}
            {% for item in archives %}
            <li>
                <a href="{{ item.Link }}" title="{{ item.Title }}">
                    {# 如果文档有缩略图,可以显示出来,增加视觉吸引力 #}
                    {% if item.Thumb %}
                        <img src="{{ item.Thumb }}" alt="{{ item.Title }}" class="related-thumb">
                    {% endif %}
                    <span class="related-title">{{ item.Title }}</span>
                    {# 简短的描述也能帮助用户判断是否点击 #}
                    <p class="related-description">{{ item.Description|truncatechars:80 }}</p> {# 截取80个字符并添加省略号 #}
                </a>
            </li>
            {% empty %}
            {# 如果没有找到相关文档,这里会显示友好提示 #}
            <li>目前没有相关推荐文档。</li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>
{# 推荐文档列表区域结束 #}

The core of this code is in{% archiveList archives with type="related" limit="5" %}.

  • archivesIt is a custom variable name that will store the recommended document list data returned by AnQiCMS.
  • type="related"Tell AnQiCMS that we need to retrieve the recommended content related to the current document now.AnQiCMS will intelligently select the most suitable document based on its internal algorithm.
  • limit="5"The number of recommended documents is limited, you can adjust this number according to the page layout and actual needs.

In{% for item in archives %}the loop,itemRepresents the data object of each recommended document. You can access various properties, such as:

  • item.Link: The URL link of the recommended document.
  • item.Title: The title of the recommended document.
  • item.Thumb: The thumbnail URL of the recommended document.
  • item.Description: A brief description of the recommended document.
  • item.CreatedTime: The publication time of the document (you may need to use{{stampToDate(item.CreatedTime, "2006-01-02")}}for formatting).

By flexibly combining these fields, you can create a recommendation list that matches the style of your website.

Advanced optimization and personalized recommendation strategies

In addition to the basic ones mentioned above.type="related"Pattern, AnQiCMS also provides more detailed control options to make your recommendation system more intelligent and personalized:

  • Keyword-based intelligent recommendation (like="keywords")If you want the recommended documents to be more focused on the keyword association of the current document, you canarchiveListaddlike="keywords"Parameter. AnQiCMS will try to match the keywords of the current document with those of other documents to provide more accurate recommendations.

    {% archiveList archives with type="related" limit="5" like="keywords" %}
        {# ... 推荐文档列表代码 ... #}
    {% endarchiveList %}
    
  • Manually specify the recommendation of related documents (like="relation")The AnQiCMS backend allows operators to manually specify other documents related to the current document. If you want to prioritize displaying these documents carefully selected by the editor, you can uselike="relation".

    {% archiveList archives with type="related" limit="5" like="relation" %}
        {# ... 推荐文档列表代码 ... #}
    {% endarchiveList %}
    

    This method requires you to manually establish associations for each document in the document editing interface on the backend.

  • Combine categories and tags for supplementary recommendationsIftype="related"Not enough recommendations are returned, or you may want to show more documents from the same category or with common tags, you can add morearchiveListLabel. For example, to get other documents under the current document category (excluding the current document itself):

    {# 假设 archive 是当前文档对象,已通过 archiveDetail 获取 #}
    {% archiveList categoryArchives with categoryId=archive.CategoryId excludeId=archive.Id limit="3" %}
        {# ... 显示分类内的其他文档 ... #}
    {% endarchiveList %}
    

    HereexcludeId=archive.IdIt is to avoid the current document being recommended in the recommendation list.

Points to note

  • Style and beautification:The code only provides the HTML structure, and the recommended visual style of the list (such as font size, image layout, spacing, etc.) needs to be beautified according to the overall design of the website, through the CSS stylesheet.
  • Handling when no content is present:Must be retained{% empty %}A tag block that ensures that when no recommended document is found, the page will not be blank, but will display a friendly

Related articles

How to get and display the name and link of the category to which the current document belongs?

On the content detail page of a website, we often hope to clearly display the classification information of the current document, such as the name of the classification and the link to that classification.This not only helps visitors better understand the content structure, but also improves the website's navigation and user experience.Safe CMS provides us with a variety of flexible ways to meet this requirement. We will discuss several methods for obtaining and displaying the category name and link of the current document in the AnQiCMS template, and you can choose the most suitable solution according to your actual template design and requirements.### Method One

2025-11-08

How to implement lazy loading of images in document content to optimize display performance?

## Optimize Website Display Performance: Practical Guide to Implementing Lazy Loading of Images in AnQi CMS In today's internet era, the loading speed of a website is crucial for user experience and search engine rankings.Large image files are often one of the main culprits slowing down website loading speeds. 幸运的是,image lazy loading (Lazy Loading) technology can effectively solve this problem.

2025-11-08

How to call and display the cover image, thumbnail, or group image of a specified document?

It is crucial to have visually appealing content when building and operating a website.AnQiCMS provides a flexible way to manage and display the images of documents (including articles, products, etc.), whether as an eye-catching cover, a clever thumbnail, or a colorful group photo.Understand how to correctly call these images, which can help you better design and optimize the user experience of the website.AnQiCMS provides several main image fields for different content types, which have clear uses in the template: * **Cover logo (Logo)**

2025-11-08

How to display the document title, publish time, and view count on the document detail page?

Manage website content in AnQi CMS and ensure its accurate and beautiful display on the front-end page, which is the core of daily operation work.For each document detail page, clearly presenting the title, publication time, and views of the document can not only effectively improve user experience, but is also an important link in the transmission of content information.The AnQi CMS provides powerful and flexible template tags, allowing us to easily meet these requirements. ### Locate the document detail page template To modify the display content of the document detail page, we first need to find the corresponding template file.In AnQi CMS template structure

2025-11-08

How to display the titles and links of the previous and next documents on the document detail page?

In website content operation, it is crucial to provide readers with a smooth reading experience.If a user finishes reading a document and can easily navigate to the previous or next related content, it not only effectively extends the user's stay on the website and increases page views, but also helps search engines better understand the structure and content relevance of the website, thereby having a positive impact on SEO.AnQiCMS (AnQiCMS) has fully considered this point in the design of template functions, providing simple and powerful tags, making it easy to display the title and link of the previous and next documents on the document detail page

2025-11-08

How to call and display the data of the custom model field in the document?

In Anqi CMS, the flexible content model is one of its core strengths, allowing us to create various information carriers such as articles, products, and more according to different business needs and define unique properties for them.How to present the data of these customized fields in the website front-end after we have set them for the document is a major concern for many users.This article will provide a detailed explanation of this process, helping you easily master the custom model fields of Anqi CMS. ### Understanding the Value of Custom Model Fields Firstly, let's clarify the importance of custom model fields.

2025-11-08

How to filter and display a document list based on specific recommendation attributes (such as 'Headline', 'Recommendation')?

The flexible application of content recommendation properties in AnQiCMS is a key link in enhancing the visibility and user experience of website content.Whether you want to highlight important news on the homepage or recommend selected content in specific sections, AnQiCMS provides a convenient and efficient solution.This article will delve into how to filter and display document lists based on specific attributes such as 'Headlines' and 'Recommendations', helping you better manage and present website content.### Part One: Understanding Recommendation Properties and Their Settings Recommendation properties are a very practical feature in the AnQiCMS content management system

2025-11-08

How to implement keyword search and display results on the document list page?

How to help visitors quickly and accurately find the information they need in the face of increasingly large amounts of website content is the key to improving user experience and website value.AnQiCMS (AnQiCMS) is deeply proficient in content management, providing us with a powerful and flexible keyword search mechanism that allows the document list page to easily implement keyword search and elegantly present the results.

2025-11-08