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