How to display a list of recommended content related to the current article on the article detail page?

Calendar 👁️ 84

In content operation, the value of a high-quality article is not only in itself, but also in its ability to guide readers to discover more valuable content.Properly displaying a list of related recommended content at the bottom of the article detail page is an effective strategy to enhance user experience, prolong visit duration, and reduce bounce rate.For users of AnQiCMS, implementing this feature is quite direct and flexible.

AnQiCMS with its concise and efficient architecture provides powerful template customization capabilities for content managers. To implement related recommendations on article detail pages, we mainly use its flexible template tag system, especiallyarchiveListTags, it can help us easily fetch and display other content closely related to the current article.

Understanding the 'Relevance' logic of AnQiCMS

In AnQiCMS, the "relevance" of content can be defined and implemented in several ways. This gives us a lot of freedom in designing recommendation lists:

  1. Automatically associate based on category or nearby content:AnQiCMS defaults to automatically matching other articles in the same category or with similar content based on the current article's category.This is the most commonly used automatic recommendation method, no additional configuration is required, the system completes it intelligently.
  2. Intelligent matching based on keywords:The website usually sets keywords (Tag) when publishing articles.AnQiCMS can use the keywords of articles to recommend content, find articles with the same or similar keywords, thereby achieving more accurate matching.
  3. Manually specified on the backend:Sometimes, we hope that certain articles have a specific recommendation relationship, and this relationship cannot be automatically identified through classification or keywords.AnQiCMS also supports manually associating some recommended articles when editing articles in the background, which provides great flexibility and precise control for operations.

After understanding this logic, we can start setting up the template on the article detail page.

Preparation: Find your template file.

Firstly, we need to locate the template file used for the article detail page. According to the template design conventions of AnQiCMS, the default template for the article detail page is usually located in your theme directory, for example:/template/你的主题名称/article/detail.html. If you have a custom template for a specific model or ID, the filename may be different, for example/template/你的主题名称/product/detail.html(if it is a product detail page) or/template/你的主题名称/article/detail-10.html(for the article with ID 10).

Find and open this file, where we will add the template code to display related recommendation content.

Practical operation: Add recommendations to the template.

In AnQiCMS templates, we mainly usearchiveListTag to get the document list. By pairing different parameters, various recommendation logic can be achieved. We usually add a recommendation content list below the article content display area.

1. Auto-recommendation: Smart matching based on categories or keywords

This is the most common and easiest way. You just need to make a simple call in the templatearchiveListtags, and specifytype="related",AnQiCMS will intelligently recommend related articles based on the current article's category, keywords, and other factors.

{# 在文章详情页的适当位置(例如文章内容下方)添加以下代码块 #}
<div class="related-content-section">
    <h2>相关推荐</h2>
    <ul>
        {# 使用archiveList标签获取相关文档,type="related"是关键 #}
        {# limit="5"表示只显示5篇推荐文章 #}
        {% archiveList relatedArchives with type="related" limit="5" %}
            {% for item in relatedArchives %}
                <li>
                    <a href="{{ item.Link }}" title="{{ item.Title }}">
                        {% if item.Thumb %}
                            {# 如果文章有缩略图,则显示缩略图 #}
                            <img src="{{ item.Thumb }}" alt="{{ item.Title }}" class="recommend-thumb">
                        {% endif %}
                        <span class="recommend-title">{{ item.Title }}</span>
                    </a>
                    <p class="recommend-desc">{{ item.Description|truncatechars:80 }}</p>
                </li>
            {% empty %}
                {# 如果没有找到相关推荐,显示友好提示 #}
                <li>目前没有更多相关推荐内容。</li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

Code analysis:

  • {% archiveList relatedArchives with type="related" limit="5" %}This is the core label, which will query the documents related to the current article from the database.
    • relatedArchivesWe give the variable name to the list of articles queried, you can use it in{% for %}Use this variable in the loop.
    • type="related"This parameter tells the system what we want is relevant recommended articles. By default, AnQiCMS will intelligently match according to the category and content of the articles.
    • limit="5": Limit the number of recommended articles to 5. You can adjust this number according to the page layout and requirements.
  • {% for item in relatedArchives %}: Traverse each recommended article obtained.
  • {{ item.Link }}Get the article link.
  • {{ item.Title }}Get the article title.
  • {{ item.Thumb }}: Get the thumbnail link of the article. In practice, you can decide whether to display the image based on whether the thumbnail exists.
  • {{ item.Description|truncatechars:80 }}: Get the article's summary and usetruncatechars:80The filter truncates it to a maximum of 80 characters to prevent it from being too long.
  • {% empty %}: It is a very practical tag, whenrelatedArchivesWhen the list is empty (i.e., no related recommended articles are found),{% empty %}and{% endfor %}the content between them will be displayed.

If you want to recommend more emphasis on article keyword matching, you can addlike="keywords"parameters:

{# 基于关键词的自动推荐 #}
{% archiveList relatedArchives with type="related" like="keywords" limit="5" %}
    {# ... 循环和显示代码同上 ... #}
{% endarchiveList %}

2. Manual recommendation: more accurate operation control

AnQiCMS also allows you to manually associate recommended articles in the backend article editing interface. If you want to display only these recommended contents carefully selected by operations personnel, you can uselike="relation"Parameter.

`twig {# If only display manually associated recommended articles #}

<h2>精选推荐</h2>
<ul>
    {% archiveList handpickedArchives with type="related" like="relation" limit="3" %}
        {% for item in handpickedArchives

Related articles

How to set and call the TDK (Title, Description, Keywords) on the AnQiCMS backend homepage?

In AnQiCMS, the TDK (Title, Description, Keywords) settings on the homepage are an indispensable part of website SEO optimization, directly affecting the first impression of the website by search engines and the willingness of users to click on the search results and enter the website.AnQiCMS as a highly SEO-friendly content management system provides an intuitive and convenient way to manage this key information.

2025-11-08

How does AnQiCMS implement pagination display on the article list page?

In website content operation, especially when the list content of articles, products, etc. becomes increasingly rich, how to efficiently display this information while ensuring user experience and website performance is a problem that needs to be carefully considered.Long list pages not only load slowly but also tend to make visitors feel tired.It is particularly important to reasonably introduce the pagination display function at this time.AnQiCMS as a powerful content management system fully considers this operation requirement.

2025-11-08

How to determine in the template whether the current page is an article detail page or a category list page, and display different content?

In the template development of Anqi CMS, it is a common requirement to display different content according to the type of the current page (whether it is an article detail page or a category list page).This not only makes the website user experience more personalized, but also provides more fine-grained control in SEO optimization.Luckyly, AnQi CMS's powerful template engine provides an intuitive way to determine the context of the current page and conditionally render accordingly.Understanding AnQi CMS template context The AnQi CMS template engine is very intelligent, it renders pages at runtime

2025-11-08

How to enable automatic image compression and WebP format conversion in AnQiCMS to improve page loading speed?

In today's fast-paced online environment, website loading speed has become a key indicator of user experience and search engine rankings.If your website has many images, they may be slowing down your website speed quietly.Fortunately, AnQiCMS fully considers this point and provides us with automatic image compression and WebP format conversion functions, which can effectively accelerate page loading and make your website fly.Why is image optimization so important?\n\nImagine when a user visits a page, if the images take a long time to display or load slowly

2025-11-08

How to call and render a custom Banner carousel in AnQiCMS template?

How to easily call and render a custom Banner carousel in AnQiCMS template?In website operation, the Banner carousel is an important element to enhance the visual appeal of the page, convey core information, and guide user behavior.AnQiCMS as a powerful content management system provides users with flexible ways to manage and call these custom Banners, allowing your website content to be displayed in a more vivid and dynamic way.### One, Back-end Management: Prepare content for Banner Carousel In AnQiCMS

2025-11-08

How to set the timing publication function when publishing articles, so that the content is displayed at the specified time?

## Master the Anqi CMS article scheduling publishing function: Let your content go online automatically during the golden time slot The timing of content release is often crucial in content operation.In order to coordinate with marketing campaigns, seize the peak of user activity, or simply maintain a stable rhythm of content output, the scheduling publishing feature is an indispensable tool for website operators.AnQi CMS understands this and provides an intuitive and convenient timed publishing option to make your content management more automated and efficient.When we carefully prepare a new article, hoping it will meet the readers at a specific time

2025-11-08

How to configure multilingual support for AnQiCMS and provide language switching functions on the website front end?

AnQiCMS (AnQiCMS) is an efficient and flexible content management system that fully considers the multilingual needs of enterprises in global operations.With its built-in features, we can easily configure multilingual support and provide visitors with intuitive language switching options on the website front-end.This not only helps us better reach users of different languages, but also lays a solid foundation for search engine optimization (SEO). Next, we will discuss step by step how to implement this feature in AnQiCMS.

2025-11-08

How to filter and display content in AnQiCMS template based on the article's 'recommended attributes' (such as headline, slideshow)?

In website content operation, displaying carefully selected high-quality content in an eye-catching manner to users is a key factor in improving user experience, guiding reading behavior, and achieving operational goals.AnQiCMS (AnQiCMS) fully understands this and provides a flexible and powerful "recommended attribute" function to make content filtering and display simple and efficient.By setting different recommendation attributes for articles, we can accurately present specified types of content in various areas of the website, whether it's the headline news on the homepage or the stunning images in the carousel, it can be easily achieved.###

2025-11-08