As an experienced security CMS website operator, I am well aware of the importance of high-quality content and refined operation for user retention and website SEO.Display related recommended articles on the article detail page, which can not only effectively extend the user's time on the site and reduce the bounce rate, but also optimize through internal links, improve the overall weight of the website, and is an indispensable part of content operation.Below, I will give a detailed introduction on how to implement this function in Anqi CMS.
Display a list of related recommended articles on the Anqi CMS article detail page
In Anqi CMS, by utilizing its powerful template tag system, we can easily implement the display of related recommended articles on the article detail page. The core of this feature lies inarchiveListThe tag allows us to flexibly call the article list based on various conditions, including retrieving recommended content related to the current article.
1. Determine the article detail page template file
Firstly, you need to find the template file of the current article detail page. According to the template design convention of Anqi CMS, the template of the article detail page is usually located in your template directory.{模型table}/detail.htmlFor example, if it is an article model, it may bearticle/detail.htmlIf you have set a custom template for a specific article or category, you need to edit the corresponding template file.
2. UsearchiveListTag to get related articles
After finding and opening your article detail page template, you can add it below the article content display area (usually<article>at the end of the tag, or in a dedicated recommendation area<div>).archiveListTags to call related article lists.
Of Security CMSarchiveListTags provide atype="related"Parameters, specifically used to retrieve recommended articles related to the current article. Here is the basic usage:
<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="article-thumb">
{% endif %}
<span class="article-title">{{item.Title}}</span>
</a>
<p class="article-description">{{item.Description|truncatechars:80}}</p>
</li>
{% empty %}
<li>暂无相关推荐文章。</li>
{% endfor %}
{% endarchiveList %}
</ul>
</div>
In this code block:
{% archiveList archives with type="related" limit="5" %}This is the core tag that indicates the system to retrieve the article list related to the current article and assign the resultarchivesVariable.limit="5"This indicates that up to 5 articles can be displayed{% for item in archives %}We useforLoop througharchivesEach article in the list.{{item.Link}}: Output the link of the article.{{item.Title}}The title of the article.{% if item.Thumb %}<img src="{{item.Thumb}}" alt="{{item.Title}}" class="article-thumb">{% endif %}Check if the article has a thumbnail, and display it if it does.item.ThumbIt will automatically fetch the thumbnail.{{item.Description|truncatechars:80}}: Output a brief description of the article, and usetruncatecharsFilter the first 80 characters to prevent the description from being too long and affecting the layout.{% empty %}<li>暂无相关推荐文章。</li>{% endfor %}If:archivesIf the list is empty (i.e., no related articles are found), then the prompt 'No related recommended articles available' is displayed.
3. Optimize the retrieval logic of related articles
type="related"The parameter defaults to fetching related articles from the same category based on the current article's ID.However, AnQi CMS provides a more intelligent and flexible way to define "relevance", helping you better control the recommendation results.
You can combinelikeParameters to refine the recommendation logic:
Get related articles based on keywords
If you want to recommend articles more closely related to the current article content, you can use the keywords of the article to match. InarchiveListthe tag withlike="keywords"The system will retrieve other articles with the same keywords based on the first keyword of the current article.
<div class="related-articles-by-keywords">
<h3>更多您可能感兴趣的</h3>
<ul>
{% archiveList archives with type="related" like="keywords" limit="5" %}
{% for item in archives %}
<li>
<a href="{{item.Link}}" title="{{item.Title}}">
<span class="article-title">{{item.Title}}</span>
</a>
</li>
{% empty %}
<li>暂无通过关键词匹配的相关文章。</li>
{% endfor %}
{% endarchiveList %}
</ul>
</div>
Make full use of this feature, be sure to fill in the "document keywords" carefully when publishing or editing articles in the background, and separate multiple keywords with English commas,The separator. The keyword library management function can help you maintain a high-quality keyword system.
Manually specify related articles
In some cases, you may want to manually specify which articles are relevant, such as series articles, special articles, etc.AnQi CMS supports setting "related documents" in the background document editing interface.archiveListUsed in tagslike="relation"Parameter to only display these manually associated articles.
<div class="handpicked-related-articles">
<h3>精选推荐</h3>
<ul>
{% archiveList archives with type="related" like="relation" limit="5" %}
{% for item in archives %}
<li>
<a href="{{item.Link}}" title="{{item.Title}}">
<span class="article-title">{{item.Title}}</span>
</a>
</li>
{% empty %}
<li>暂无手动精选推荐文章。</li>
{% endfor %}
{% endarchiveList %}
</ul>
</div>
This means that in the Anqi CMS backend content management, the document editing page will have corresponding fields or options that allow operators to manually select associated articles.As an operation staff, you should actively configure these "related documents" when publishing content, based on the relevance of the article and the potential needs of users, to provide more accurate recommendations.
4. Front-end Style and User Experience
Although the above code provides the basic structure of recommended articles, the actual display effect still needs to be beautified through CSS styles. You can follow the overall style of the website torelated-articles-section/article-thumb/article-titleAdd appropriate styles to elements to ensure the recommendation list is beautiful and easy to read.A good user experience can further improve the click-through rate of recommended content, thereby achieving the purpose of attracting and retaining users.
By following these steps and techniques, you can effectively display a list of recommended articles related to the current article on the Anqi CMS article detail page, optimize the user experience, and enhance the SEO performance of the website.
Frequently Asked Questions (FAQ)
Ask: I added the related article code, but the article detail page does not display any recommended content, why is that?Answer: This may be caused by several reasons. First, please check if your template file has been saved and uploaded to the server correctly. Secondly, ensure that you arearchiveListThe parameter settings used in the label are correct, especiallytype="related". If usedlike="keywords"orlike="relation"Please confirm whether the article itself has set keywords or manually associated with other articles in the background.Finally, check if your website has enough articles, and that these articles match the current article in categories, keywords, or manual associations.If the number of articles is low or the relevance data is insufficient, the system may not be able to match recommended content.
Question: How to make the recommendation of related articles more accurate, rather than just displaying adjacent articles of the same category?Answer: To improve the accuracy of recommendations, you can combinelikeparameters for optimization. When a large number of keywords are used in your content system, uselike="keywords"Can the system recommend content based on the keywords of the article.This means that if two articles share the same keywords, they are more likely to be recommended.like="relation"Only display these manually selected related articles, which is very useful when creating series articles or special topics, ensuring the strong relevance of recommended content.
Ask: Will the list of related recommended articles affect the loading speed of the website?Answer: Anqi CMS is developed based on Go language, with a high-performance architecture, and the system performs excellently in handling content calls and data queries.In most cases, adding a related recommendation list containing a small number of articles (such as 5-10) has a negligible impact on website loading speed.If your website traffic is very high and you are using a lot of complex data in the recommendation list, you may need to pay attention to performance.limitParameters control the number of recommended articles and ensure that resources such as images are optimized (such as automatically compressing large images, converting to Webp format, etc.), these features are all provided in the content settings of Anqi CMS.