How to display a list of recommended articles related to the current article?

Calendar 👁️ 67

In website operation, recommending relevant articles to readers is an important strategy to improve user experience, extend user stay time, and optimize SEO.After a reader finishes reading an article, if they can immediately see recommendations highly relevant to the current content, it will undoubtedly greatly increase their interest in continuing to explore the website.AnQi CMS understands this need and provides powerful and flexible functions to help users easily achieve this goal.

The 'Related Documents' feature in AnqiCMS

One of the core strengths of AnQi CMS lies in its powerful content management and template tag system. To display a list of recommended articles related to the current article, we mainly usearchiveListThis template tag.archiveListTags can not only be used to display regular article lists, category article lists, but also especially support displaying "related documents", which is exactly the core function we need.

Core tags:archiveListApplication

archiveListThe tag is used to retrieve article data from the database and display it in a list. It has rich parameters that can help us precisely control the filtering, sorting, and display of articles.

Basic usage: Display the recommended list related to the current article

Of Security CMSarchiveListTags are combinedtype="related"After the parameters, it can intelligently recognize the article being displayed on the current page and automatically fromin the same categoryFind similar or adjacent articles to the current article as recommendations.

This is an example of the template code for implementing this function:

<div class="related-articles-section">
    <h3>相关推荐文章</h3>
    <ul>
        {% 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>
                    <span class="related-date">{{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
                </a>
            </li>
            {% empty %}
            <li>暂无相关推荐文章。</li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

Code analysis:

  • {% archiveList archives with type="related" limit="5" %}This is the core tag.
    • archives: The variable name you define for the recommended article list, you can use it in{% for %}Use it in the loop.
    • type="related"This parameter tells AnQi CMS that we want to get articles related to the current article.The AnQi CMS will automatically match the current article based on the category, ID, and other information.
    • limit="5": Limit the number of recommended articles to 5. You can adjust this number based on the page layout and requirements.
  • {% for item in archives %}: Loop through the list of recommended articles obtained.
    • item.Link: The link address of the recommended articles.
    • item.Title:Recommended article title.
    • item.Thumb:Recommended article thumbnail (if any). The thumbnail uploaded during document editing in the background will be displayed here.
    • stampToDate(item.CreatedTime, "2006-01-02"): Use.stampToDateThe filter formats the creation timestamp of the article into the date format of "Year-Month-Day".
  • {% empty %}: This is a very practical tag. IfarchiveListNo matching recommended articles were found.{% empty %}and{% endfor %}The content between the brackets will be displayed, avoiding blank pages or error prompts, thus improving user experience.

More accurate recommendation strategy: based on keywords or manual association.

In addition to automatic recommendations based on categories,archiveListtags also allow you to refine the definition of “relevant” throughlikeparameters, further defining the “relevant” concept.likeparameters need to be used withtype="related"together.

  1. Based on keyword recommendation (like="keywords")If you want to match the keywords of the article more precisely, you canarchiveListadd alike="keywords"Parameters. Anqi CMS will search for other articles containing the same keywords set in the current article under the same model.

    <div class="related-articles-by-keywords">
        <h3>根据关键词推荐</h3>
        <ul>
            {% archiveList keywordArchives with type="related" like="keywords" limit="3" %}
                {% for item in keywordArchives %}
                <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
                {% empty %}
                <li>暂无根据关键词推荐的文章。</li>
                {% endfor %}
            {% endarchiveList %}
        </ul>
    </div>
    
  2. Based on manual association recommendation (like="relation")In the Anqi CMS backend document editing interface, you can manually link other articles as recommendations.This method is the most accurate because it is completely controlled by the operator.To call these manually associated articles, you can uselike="relation"Parameter.

    <div class="related-articles-manual">
        <h3>编辑精选推荐</h3>
        <ul>
            {% archiveList manualArchives with type="related" like="relation" limit="4" %}
                {% for item in manualArchives %}
                <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
                {% empty %}
                <li>暂无编辑精选推荐文章。</li>
                {% endfor %}
            {% endarchiveList %}
        </ul>
    </div>
    

Flexibly display recommended article information

In the above examples, we mainly displayed the article title, link, thumbnail, and publish time. In fact,itemVariables provide more field information for articles, and you can choose and combine them according to your design needs:

  • item.Description: The article's introduction or abstract. If the content is long, it can be combined withtruncatecharsFiltered by the filter, for example{{ item.Description|truncatechars:80 }}.
  • item.Views: The number of views of the article, which can show the popularity of the article.
  • item.CategoryId: The ID of the category to which the article belongs, combinedcategoryDetailTags can obtain the name and link of the category.
  • item.Logo: The article cover main image (usually a larger image).
  • item.Images: The article cover group image, this is an array, you can display multiple images by looping.

Example: Combine summary and views.

<div class="related-articles-full">
    <h3>更多相关推荐</h3>
    <ul>
        {% archiveList moreArchives with type="related" limit="6" %}
            {% for item in moreArchives %}
            <li>
                <a href="{{ item.Link }}">
                    <h4 class="related-title">{{ item.Title }}</h4>
                    {% if item.Description %}
                        <p class="related-description">{{ item.Description|truncatechars:120 }}</p>
                    {% endif %}
                    <div class="related-meta">
                        <span>发布于:{{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
                        <span>阅读量:{{ item.Views }}</span>
                    </div>
                </a>
            </li>
            {% empty %}
            <li>暂无更多相关推荐。</li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

Summary

Utilizing the powerful AnQi CMSarchiveListTagging and flexible parameter settings allow you to easily display a diverse list of recommended articles on the current article page.Whether it is an intelligent recommendation based on article classification, or an accurate match based on keywords, or even high-quality content manually associated by the operator, Anqi CMS can provide a simple and efficient implementation method.These features not only help to enhance the content depth and user engagement of the website, but also play a positive role in search engine optimization.


Frequently Asked Questions (FAQ)

1. Why is my recommended article list not displaying any content?

  • Check the article properties:Make sure the current article is set to a category.type="related"The pattern mainly relies on the classification information of the article to find related content.
  • Number of contents:Ensure your website has enough content, especially the number of articles in the same category. If there are too few articles, it may not be possible to find suitable recommendations.
  • Keyword/related settings:If you have usedlike="keywords"orlike="relation"Please enter the parameters,

Related articles

How to display the detailed content page of articles or products?

In Anqi CMS, the display of article or product detailed content pages is the core link of website content operation.A well-designed, comprehensive detail page that can effectively convey content value and enhance user experience and search engine friendliness.Strong and flexible tool set provided by AnQi CMS, allowing us to easily achieve these goals. ### The Foundation of Content: Content Model and Template Files In Anqi CMS, all articles and products are unified as "content" (archive). They can exhibit different forms

2025-11-09

How to get and display all articles under a specific category?

In website content management, effectively organizing and displaying articles is the key to improving user experience and the clarity of the website structure.Strong and flexible template tag features are provided by AnQi CMS, allowing you to easily retrieve and display all articles under a specific category.Ensure content structure clarity: The foundation of backend category settings Before starting operations at the template level, we must first ensure that the content structure of the backend is clear and reasonable.The AnQi CMS category management feature is located under the "Content Management" module, where you can create and manage various article categories, such as "Company News"

2025-11-09

How to display the latest articles or product lists on the website?

In Anqi CMS, it is an important aspect to manage and display website content, especially to allow visitors to see the latest published articles or product dynamics, which is crucial for enhancing user experience and website vitality.A dynamically updated website can not only attract users to continue visiting, but also is very beneficial for search engine optimization (SEO).AnQi CMS provides a powerful and flexible tag system, allowing us to easily meet this requirement.### Core Tool: `archiveList` Tag The most core tool to display the latest articles or product lists on any page of the AnQi CMS website is

2025-11-09

How to use the anchor text feature of AnQiCMS to improve the display effect of internal links?

The internal links of the website are like a complex maze, guiding users and search engines through various pages.And the anchor text, which is the 'road sign' on this map, directly determines the efficiency and user experience of navigation.A clear and relevant anchor text not only enhances user click-through intention but is also an important basis for search engines to understand page content and evaluate page authority.AnQiCMS as an efficient content management system is well-versed in this, providing a strong and flexible anchor text feature to help us easily improve the display effect of internal links.###

2025-11-09

How to retrieve and display the list of all categories on the website?

In Anqi CMS, the website category list is the foundation for building clear navigation, enhancing user experience, and optimizing search engine rankings.Whether it is to establish a classification system for articles, products, or other content models, AnQiCMS provides flexible and powerful tools to easily obtain and display these classifications.One of the core concepts of AnQiCMS is to make content management efficient.It organizes the content into different "content models", such as common article models and product models.Each content model can have an independent classification system. Understanding this is the first step to obtaining the classification list.

2025-11-09

How to display subcategories on the category page, or show the article list when there are no subcategories?

In website operation, the content display logic of category pages has an important impact on user experience and information architecture.We often encounter such needs: when there are subcategories under a category, it is preferred to display these subcategories to facilitate users in navigating more finely;And if the category does not have subcategories, then directly display the list of articles under the category, to avoid the page content being empty or the navigation level being too deep.AnQiCMS (AnQiCMS) provides flexible template tags that can easily achieve this dynamic display effect.### Understand the dynamic display logic of the category page To implement the intelligent display of the category page

2025-11-09

How to display a list of all independent web pages of the website?

In AnQiCMS, the independent pages of a website play a crucial role, usually carrying core information such as "About Us", "Contact Information", "Privacy Policy", etc. They are an indispensable part of building website trust and perfecting the information architecture.This article will introduce how to effectively manage and display these independent page lists in Anqi CMS. ### Understanding the 'Independent Page' in AnQi CMS In the context of AnQi CMS, what we refer to as the 'Independent Page' corresponds to the 'Single Page' feature in the system.These pages and articles

2025-11-09

How to retrieve and display detailed content of a specific independent page?

Our Anqi CMS provides great flexibility in content management, especially for pages that need to display independent, static information, such as "About UsThese are called "independent pages" or "single pages", their content is usually relatively fixed, but they also need to be independently displayed and have search engine friendly features.How can we efficiently retrieve and display the detailed content on these specific independent pages in AnQi CMS?

2025-11-09