How to use the `archiveList` tag's `type="related"` feature to display related article recommendations?

Calendar 👁️ 63

On your website, when visitors finish reading an article, if they can see other related content in time, this can not only significantly improve the user experience, reduce the bounce rate, but also effectively increase the page views and dwell time of the website. AnQi CMS provides a very convenient tag for this:archiveList,combined with ittype="related"properties, you can easily achieve this function

UnderstandingarchiveListwithtype="related"working principle

archiveListIs an AnQi CMS feature-rich content list call tag, which allows you to obtain article lists based on various conditions (such as category ID, module ID, recommended attributes, etc.). When we willtypeset the attribute to"related"When, this tag will intelligently recognize the article being displayed on the current page and try to find other related articles to recommend.

This 'related' logic is multifaceted.The system will first try to retrieve nearby articles from the same category as the current article ID for related recommendations.archiveListthe tags also providelikeParameter, it has two main uses:

  1. Keyword-based recommendation (like="keywords")When you set clear keywords for an article (you can fill in keywords during backend article editing, and multiple keywords are separated by English commas), and you have usedlike="keywords"The parameter, the system will match other articles with the same keywords on the website based on the first keyword of the current article.This is very useful for a website with clear content themes and keyword management norms.

  2. Recommended based on manual association (like="relation")Sometimes, you may want to control the recommendation of related articles more accurately.In the AnQi CMS backend article editing interface, you can manually specify other articles associated with the current article.like="relation"parameter,archiveListTags will only display these articles you have manually associated, providing you with great flexibility.

If you have not specifiedlikeParameters, the system will default try to recommend articles similar to the current article in the same category.

How to implement related article recommendations in the template

Generally, related article recommendations appear below the content of the article detail page. The following is an example of a typical template code that shows how to usearchiveListtags to display related articles:

{# 假设您正在文章详情页的模板文件中 #}
{# 在此处展示完当前文章的主要内容,例如:{{archive.Content|safe}} #}

<div class="related-articles-section">
    <h2>相关推荐</h2>
    <ul>
        {% archiveList relatedArticles with type="related" limit="5" like="keywords" %}
            {# 上述代码会尝试获取最多5篇基于关键词的相关文章。
               如果想基于手动关联推荐,请将 like="keywords" 改为 like="relation"
               如果想基于同分类临近文章推荐(默认行为),可以移除 like 参数。
            #}
            {% for item in relatedArticles %}
            <li>
                <a href="{{item.Link}}" title="{{item.Title}}">
                    {% if item.Thumb %}
                        <img src="{{item.Thumb}}" alt="{{item.Title}}">
                    {% else %}
                        {# 如果没有缩略图,可以显示一个默认图片或文字 #}
                        <img src="/public/static/images/default-thumb.jpg" alt="{{item.Title}}">
                    {% endif %}
                    <h3>{{item.Title}}</h3>
                    <p>{{item.Description|truncatechars:80}}</p>
                    <div class="meta-info">
                        <span>发布于:{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                        <span>阅读量:{{item.Views}}</span>
                    </div>
                </a>
            </li>
            {% empty %}
                {# 如果没有找到任何相关文章,这里会显示提示信息 #}
                <li><p>暂无相关文章推荐。</p></li>
            {% endarchiveList %}
        </ul>
</div>

In this code block:

  • We first created adivcontainer to wrap the entire related recommendation module.
  • {% archiveList relatedArticles with type="related" limit="5" like="keywords" %}This line is the core, it callsarchiveList.
    • relatedArticlesis the variable name defined for the article list we obtained, you canforUse it in the loop.
    • type="related"Clearly tell the system that we want to get related articles.
    • limit="5"Limited to displaying up to 5 articles at most. You can adjust this number based on the page layout and requirements.
    • like="keywords"Specified that the system should match related articles according to the keywords of the current article. If you wish to recommend based on manual association, you can change it tolike="relation".
  • {% for item in relatedArticles %}Loop through each relevant article obtained.
  • item.Link/item.Title/item.Thumb/item.Description/item.CreatedTime/item.ViewsThey are all article objectsitemFields that can be called, representing the article link, title, thumbnail, introduction, creation time, and page views.stampToDateIt is an auxiliary label for formatting timestamps, making the date display more friendly.
  • {% empty %}It is a very practical label, ifarchiveListNo matching related articles were found.{% empty %}The content within the tags will be displayed, avoiding blank or unfriendly prompts on the page.

Optimization and注意事项

  • Style customization: The above code only shows the structure, you need to customize it according to the overall style of the website..related-articles-sectionAdd the corresponding CSS styles to the internal elements to make the recommendation module look beautiful and generous.
  • Content Management:To ensure that the related recommendation feature works effectively, it is recommended that you fill in the article keywords carefully when editing articles in the background, or manually associate some high-quality articles that are highly relevant to the current content of the article.
  • Location selection: The related recommendation module is usually placed below the article content, above the comment area, or in the sidebar, and the specific location can be adjusted according to your website layout and user habits.

By using the above method, you can provide your readers with relevant article recommendations flexibly and efficiently on the Anqi CMS website, thereby enhancing user experience and content value.


Frequently Asked Questions (FAQ)

Q1:likeTwo modes of parameters (keywordsandrelation) What are the differences?

A1:like="keywords"Content-based automated recommendation.The system will extract the keywords of the current article, then match the keywords with other articles on the website to find similar content for recommendation.This method depends on the accuracy of the keywords in your article.like="relation"The pattern is based on the associated articles manually set during the background article editing and recommended.If you want to precisely control the recommended content, you can choose manual association; if you want the system to match content intelligently, then choose keyword mode.

Q2: What will the page display if no related articles are found?

A2: In the sample code, we used{% empty %}Label. This means ifarchiveListThe label did not find any matching related articles after execution, the page will display{% empty %}The content inside the label, for example, "No related articles recommended." such prompt information. If there is none{% empty %}Label, then this area will be blank, no content or error will be displayed.

Q3: How to ensure that the recommended articles are truly 'relevant' rather than random?

A3: The key to ensuring the quality of relevant article recommendations lies in the backend content management.

  1. Keyword accuracy: When editing an article, be sure to fill in keywords that are highly relevant and accurate to the content of the article.
  2. Categorization planning: Categorize the article into the appropriate category, as the system will prioritize recommending articles in the same category by default.
  3. Manual associationFor particularly important articles, you can use the manual association feature on the backend to directly specify several high-quality related articles.
  4. Content optimizationEnsure that the content of the article itself is clear in its theme, which helps the system better understand its main point and match it.

Related articles

How to implement the previous/next document function using `prevArchive` and `nextArchive` tags?

When you operate a website, providing a smooth reading experience for users is one of the key factors in enhancing website stickiness.When a user finishes reading a document, if they can easily jump to the previous or next related article, it will undoubtedly greatly increase their stay time on your website.AnQiCMS (AnQiCMS) understands this and provides very intuitive and powerful `prevArchive` and `nextArchive` tags to help you easily implement this feature.

2025-11-08

How to display article title, content, images, etc. on the document detail page using the `archiveDetail` tag?

Manage website content in Anqi CMS, the document detail page is undoubtedly the core position for users to obtain information.How to present each carefully written article, its title, content, images, and various additional information accurately and vividly to the user, this requires the clever use of our `archiveDetail` tag.This tag is specifically designed to display the details of a single document, and its flexible use will help you easily build a feature-rich and smooth experience detail page.

2025-11-08

How does the `archiveList` tag display the article list based on categories, recommended attributes, or custom sorting?

In the Anqi CMS template system, the `archiveList` tag is the core tool for building dynamic content lists.Whether it is a blog article list, product display page, or news information module, `archiveList` can help you accurately filter, sort, and present content according to your diverse needs, bringing vitality to your website content area.

2025-11-08

How are the `pageList` and `pageDetail` tags used to display single-page content such as 'About Us'?

In website operation, content such as 'About Us', 'Contact Information', or 'Service Introduction' usually exists as independent pages, which we call 'single pages'.They do not update as frequently as blog posts, but they are essential core information for the website.AnQi CMS provides the `pageList` and `pageDetail` tags, allowing you to manage and display these single-page contents flexibly and efficiently.

2025-11-08

How does the `archiveParams` tag display custom field data of the document on the frontend page?

In AnQi CMS, the flexibility of content is one of our core advantages for website operation and content management.In addition to standardized fields such as titles and text, we often need to add specific custom information for different types of content, such as the 'brand', 'model', and 'origin' of products, or the 'author' and 'source' of articles, etc.These custom fields greatly enrich the dimensions of content display, but how to accurately and flexibly present these meticulously entered backend data on the front-end page is an important consideration during template development. At this time

2025-11-08

How to build a complex search interface for product filtering or property filtering using the `archiveFilters` tag?

In the era of content explosion, when users visit websites, they often hope to quickly find the content they are interested in.Whether it is browsing a large number of products on e-commerce platforms or looking for housing that meets your preferences on real estate websites, a powerful and easy-to-use filtering and search interface is the key to improving user experience. AnQiCMS (AnQiCMS) knows this and provides a powerful `archiveFilters` tag for this purpose.This tag can help you easily build a complex product or property filtering interface, making your website content more discoverable and interactive

2025-11-08

How to display the associated tags of the `tagList` and implement a tag cloud effect?

## Utilizing AnQiCMS's `tagList` tag, easily implement document association and tag cloud display Tags play a crucial role in website content operations.They can not only help users quickly find the content they are interested in, improve the convenience of site navigation, but also optimize the search engine's understanding of the website's content through keyword aggregation, thereby bringing better SEO performance.AnQiCMS fully considered this requirement, built-in powerful tag features, and provided flexible template tags `tagList`

2025-11-08

How to retrieve and display the details of a specific `tagDetail` tag?

AnQiCMS (AnQiCMS) provides a series of powerful template tags to help website operators efficiently display content.Among them, the `tagDetail` tag is a key tool for obtaining and displaying specific tag details.Whether it is to build a beautiful tag detail page or to refer to related data of tags on other pages, `tagDetail` can provide a flexible and intuitive solution.

2025-11-08