How to display a list of related articles based on the keywords or custom associations of an article?

Calendar 👁️ 69

In website content operation, providing users with a list of relevant articles can not only effectively extend the time visitors spend on the website, reduce the bounce rate, but also guide users to discover more interesting content, optimize the internal traffic path, and have a positive impact on SEO performance.AnQiCMS (AnQiCMS) fully understands this need and provides flexible and powerful functions to allow us to easily display related article lists based on the keywords of the article or custom associations.

Understanding the article association logic of Anqi CMS

Anqi CMS was designed from the beginning to consider the relevance between content. It provides two main ways to help us build and display the relationship between articles: one is throughKeywordsPerform automatic matching, the other is throughManual setup on the back-endEstablish an accurate custom association. These two methods have their respective focuses, and can be flexibly chosen according to actual operational needs.

Method one: Use keywords to automatically associate articles

When we publish an article, we usually set keywords for the article.These keywords not only help search engines understand the article theme, but are also an important basis for Anqi CMS to achieve automatic association of articles.The Anqi CMS can intelligently retrieve and recommend other articles similar to the current article's keywords in the system.

How to set article keywords:

In the AnQi CMS backend, when we enter the "Content Management" module and go to the "Publish Document" page, we will see an input box for "Document Keywords". Here, we can manually enter keywords highly relevant to the article content, with multiple keywords separated by English commas,Perform separation. In addition, Anqi CMS also provides a keyword library management function, which makes it convenient for us to select from a preset keyword library or automatically expand keywords, thereby improving the efficiency and relevance of keyword settings.

Call related articles based on keywords in the template:

We need to use the Anqin CMS provided in the article detail page template to display the article list automatically associated with keywords on the website page.archiveListLabel. This label has rich parameters that can help us accurately control the acquisition and display of content.

For example, to display 5 articles related to the current article's keywords at the bottom of the article detail page, we can write the template code like this:

{# 假设这里是文章详情页的模板代码 #}

<h3>相关推荐</h3>
<div>
    {% archiveList relatedByKeywords with type="related" like="keywords" limit="5" %}
        {% for item in relatedByKeywords %}
        <li>
            <a href="{{item.Link}}">{{item.Title}}</a>
            {# 如果需要显示简介或缩略图,可以进一步添加 #}
            {# <p>{{item.Description|truncatechars:50}}</p> #}
            {# {% if item.Thumb %}<img src="{{item.Thumb}}" alt="{{item.Title}}" />{% endif %} #}
        </li>
        {% empty %}
        <li>暂无相关推荐文章。</li>
        {% endfor %}
    {% endarchiveList %}
</div>

In this code block:

  • type="related"It indicates the related articles we want to retrieve.
  • like="keywords"Tell the system clearly to match relevant content based on the keywords of the article. Anqi CMS will find the most relevant other articles based on the first keyword of the current article.
  • limit="5"The number of displayed articles is limited to 5.

In this way, the system intelligently recommends content based on the keywords of the article, saving the麻烦 of manual association, especially suitable for websites with a large amount of content and frequent updates.

Method two: Customize associated articles to achieve precise recommendations

Sometimes, we may want to control more precisely which articles are associated with each other, rather than relying entirely on automatic keyword matching.For example, the preceding and following articles of a series, or specific product introductions and press releases manually associated with marketing activities, etc.AnQi CMS also supports this highly customizable association method.

How to set up custom association:

When editing specific documents in the AnQi CMS backend under 'Content Management', in addition to common fields such as keywords and descriptions, there will also be an option to set 'related documents'.Here, we can manually select and associate one or more articles that have a specific logical relationship with the current article.This manually set association has the highest priority and can ensure that we accurately recommend content according to our operational strategy.

Call custom associated articles in the template:

Similar to association based on keywords, calling custom associated articles also needs to usearchiveListtags, justlikethe parameters are different.

For example, to display 3 related articles manually set on the article detail page, the template code can be written as follows:

{# 假设这里是文章详情页的模板代码 #}

<h3>您可能也喜欢</h3>
<div>
    {% archiveList customRelations with type="related" like="relation" limit="3" %}
        {% for item in customRelations %}
        <li>
            <a href="{{item.Link}}">{{item.Title}}</a>
            {# 同样,可以根据需要添加更多字段 #}
        </li>
        {% empty %}
        <li>暂无特别推荐。</li>
        {% endfor %}
    {% endarchiveList %}
</div>

The key point lies inlike="relation"It indicates that the AnQi CMS only retrieves the related articles manually set in the background document editing interface. This provides great convenience for those who need highly refined operation scenarios.

Flexible display and optimization

No matter which way of association you choose,archiveListEach tag returnsitemit includes rich information such as the article,Title(Title),Link(Link),Description(Summary),Thumb(thumbnail),CreatedTime(Publish time) and others. We can freely combine these fields according to the needs of template design to build a diverse style of related article list.

For example, if you want the list to display more richly, you can modify it like this:

{# 这是一个更丰富的相关文章列表示例 #}
<h3>精选内容</h3>
<ul class="related-articles-list">
    {% archiveList featuredRelations with type="related" like="keywords" limit="4" %}
        {% for item in featuredRelations %}
        <li class="article-item">
            {% if item.Thumb %}
                <div class="article-thumb">
                    <a href="{{item.Link}}"><img src="{{item.Thumb}}" alt="{{item.Title}}"></a>
                </div>
            {% endif %}
            <div class="article-info">
                <h4><a href="{{item.Link}}">{{item.Title}}</a></h4>
                <p class="article-description">{{item.Description|truncatechars:80}}</p>
                <span class="article-date">{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
            </div>
        </li>
        {% empty %}
        <li class="no-results">暂时没有找到其他相关文章。</li>
        {% endfor %}
    {% endarchiveList %}
</ul>

Please note,item.Description|truncatechars:80This style uses the built-in filter of Anqi CMS, which can truncate the article summary to the specified character length and automatically add an ellipsis to ensure the page layout is neat.stampToDateThe tag makes it convenient to format the timestamp into the date format we need.

Summary

AnQi CMS enables us to conveniently display related article lists based on keywords or custom settings through its carefully designed template tags and flexible configuration options.Whether it is pursuing keyword association for automation and large-scale content, or needing fine-grained control and strong logical manual association, AnQi CMS can provide effective solutions to help us better organize content and improve the user experience and operational efficiency of the website.


Frequently Asked Questions (FAQ)

1. If both keyword association and custom association are set, which method will be displayed first?

In Anqi CMS, when you usetype="related"label and specifylike="relation"Whenlike="keywords"theselikeThe parameters are mutually exclusive, you cannot use them in the samearchiveListtag at the same time to get related articles from the same batch, but you can call two of them separatelyarchiveListTags, displaying lists of associated articles of two categories respectively.

2. What will be displayed in the related articles list if the article has not set keywords or custom associations?

If the article has not set any keywords and has not manually associated any articles usingarchiveListthe tags have not been specifiedlike="keywords"orlike="relation"or if these two do not match, thenarchiveListwithin the tag,{% empty %}The code block will be executed. Usually, we will{% empty %}place a prompt, such as 'No relevant recommendations' or 'No other relevant articles found', to avoid blank pages.

3. 'How does the retrieval of relevant documents based on the first keyword in the document' work?

When you uselike="keywords"When the parameter is set, Anqi CMS will intelligently extract the input from the current article's "Document Keywords" fieldThe firstkeyword. Then, the system will search the entire content library based on this keyword

Related articles

What sorting and filtering options does AnQiCMS provide to control the display order of list content?

How to efficiently display and organize content in website operation directly affects the user experience and the efficiency of information transmission.For users who use AnQiCMS, the system provides various flexible sorting and filtering options to help us accurately control the display order of list content. Whether it is articles, products, or other custom content types, they can be presented to visitors in the most business-friendly way possible.The AnQi CMS has given the control of content display order to the user, which is mainly realized through a powerful template tag system and backend management settings.Through these features

2025-11-08

How can you list the latest articles or products under a specified category in AnQiCMS?

Manage website content in AnQiCMS, often need to display relevant information according to different themes or sections.For example, you may want to display the latest articles under the "Company News" category in some area of the homepage, or show the latest products under the "Hot New Products" category in the sidebar of the product page.AnQiCMS provides flexible and powerful template tags, allowing you to easily implement these content call requirements.Understanding the content organization of AnQiCMS is the key to efficiently utilizing its features.The system distinguishes different types of content through the "content model", such as article models and product models

2025-11-08

How to use Django template engine syntax in AnQiCMS template to control the content display logic?

AnQiCMS is an efficient content management system developed based on the Go language, its template system uses a syntax similar to Django's template engine, which is undoubtedly an advantage for those familiar with web development to quickly get started and implement powerful content display logic.It allows us to flexibly control the presentation of content at the template level without writing complex backend code.To understand how to use this GoLang implemented Django template engine syntax in AnQiCMS templates to control content display logic

2025-11-08

Do I want to use a unique display template for specific articles or categories, does AnQiCMS support this?

In website operation, we often encounter such needs: some articles or categories, due to the particularity of their content or marketing needs, we hope to give them a completely different display style from the rest of the website.This personalized display requirement is particularly important in today's increasingly rich content.So, does AnQiCMS support using a unique display template for specific articles or categories?The answer is affirmative, and it provides powerful and flexible features to support you in achieving this goal.Why do you need a dedicated template?\n\nImagine

2025-11-08

How to call and display the custom fields of an article on the article detail page?

In Anqi CMS, the content display of the article detail page is highly flexible, especially for fields customized through the content model.These custom fields can help us manage and display different types of information more precisely, such as product prices, authors' origins, and property layouts, etc.How can you accurately call and display the content of these custom fields on the article detail page?This article will introduce this process in detail. ### 1. Custom field creation and filling: laying the content foundation In AnQi CMS

2025-11-08

How to display the 'Previous' and 'Next' article links and titles on the article detail page?

It is crucial to enhance user experience and content discoverability in website operation.When a reader is immersed in an article, providing navigation links to the "previous article" and "next article" can not only guide them to continue browsing the website's content but also effectively reduce the bounce rate and optimize the on-site SEO structure.For those of us using the AnQiCMS website to manage, implementing this feature is both simple and efficient.AnQiCMS provides a straightforward and powerful template tag system, making it easy to integrate 'Previous Article' and 'Next Article' links on article detail pages

2025-11-08

How can I build and display a multi-level nested category navigation menu?

Building and displaying multi-level nested category navigation menus in Anqi CMS is an important aspect of website content organization and user experience optimization.A well-designed, hierarchical navigation not only helps visitors quickly find the information they need, but also provides clear website structure signals to search engines, thereby improving SEO effectiveness. AnQi CMS is an enterprise-level content management system developed in Go language, with flexible content models and powerful template tags, making it very intuitive and efficient to implement multi-level classification navigation.Next, we will explore how to step by step build such navigation

2025-11-08

How to display the top-level category list of a specific content model on the homepage or sidebar?

In AnQi CMS, managing website content, we sometimes need to clearly display the top-level category list of a specific content model at key positions such as the homepage or sidebar.This not only effectively guides visitors to browse the website content and improve user experience, but is also an important aspect of website content architecture optimization and search engine friendliness.Using AnQiCMS's flexible template system and powerful tag features, it is direct and efficient to meet this requirement. ### Understanding the Core: Content Model and Classification The core of content management in Anqi CMS lies in the "content model".You can create different content models based on business requirements

2025-11-08