As a website operator who deeply understands the operation of AnQiCMS, I know that high-quality content and user experience are crucial to the success of a website.The related articles can not only effectively extend the user's stay on the site, increase the page views, but also benefit the internal link optimization (SEO) of the website.AnQiCMS provides a flexible way to retrieve and display these related contents, meeting the operational needs of different scenarios.

Overview of the mechanism for linking articles in AnQi CMS

In AnQiCMS, the main way to get related articles is through the core ofarchiveListTemplate tag implementation. This tag has powerful filtering and sorting capabilities, and can retrieve article lists based on various conditions, including a special one for associating articles.type="related"Parameters. By adjustingarchiveListThe parameter allows us to easily implement article recommendations based on categories, keywords, or manual association in the background.This provides operators with great freedom to ensure that users can always find more content they are interested in.

Retrieve associated articles based on the article category

The most common way to associate articles is to recommend them based on the category they belong to.When a user browses a specific article, they are usually also interested in other articles in the same category.In AnQiCMS, we can get the category ID of the current article and then usearchiveListUse tags to retrieve other articles in the category.

Firstly, we need to obtain the category ID of the current article in the template. This can be done byarchiveDetailTag implementation. Once we get the category ID, we can use it asarchiveListlabel'scategoryIdA parameter value. For example, if the current article's category ID is123, we can setcategoryId="123"Fetch the articles under this category. At the same time, to avoid duplicate display of the current article, we usually need to configure the relevant article list appropriately in the background.limitThe parameter can control the number of articles displayed, ensuring the simplicity and efficiency of the related article area.

Get related articles based on keywords or tags.

In addition to categories, keywords or tags are also important links connecting the content of articles.AnQiCMS allows us to intelligently recommend related content based on the keywords of the current article.This method is particularly effective for articles that cross categories but have similar themes.

To implement keyword-based associated article recommendation, we still usearchiveListTags, and settype="related". On this basis, by addinglike="keywords"Parameter, AnQiCMS will automatically parse the keywords or tags of the current article and search for other articles with similar content accordingly.This means that if multiple articles use the same core keywords or tags, they will be interconnected to form a content matrix, greatly improving the discoverability of the content.The importance of setting keywords and tags accurately when publishing articles is fully manifested at this moment.

Through manual association to obtain articles

In certain special cases, website operators may need to control the display of related articles more finely, for example, when promoting specific content, creating special topic pages, or guiding users to read specific series of articles.AnQiCMS provides the function of manually associating articles for this.

You can use it to specify the related articles of an article explicitly in the backgroundarchiveListLabel collaborationtype="related"andlike="relation"Parameters. This means that the system will no longer automatically calculate relevance based on categories or keywords, but will only display those articles that are manually specified by the operations personnel in the backend editing interface as relevant content for the current article.This feature grants the operation personnel the highest degree of freedom, enabling them to accurately guide users to the preset content path and implement more complex operation strategies.

A practical example of calling related articles in the AnQiCMS template

To demonstrate how to obtain and display related articles in the AnQiCMS template more intuitively, here is a comprehensive example.Suppose we are at the bottom of an article detail page, hoping to display articles in the same category, recommended based on keywords, and manually associated.

{# 首先,获取当前文章的ID和分类ID #}
{% archiveDetail currentArticleId with name="Id" %}
{% archiveDetail currentCategoryId with name="CategoryId" %}

<div class="related-articles-section">
    <h3>更多相关文章</h3>

    {# 方式一:根据当前文章分类ID获取关联文章 #}
    <div class="related-by-category">
        <h4>同类推荐</h4>
        <ul>
            {% archiveList categoryRelatedArchives with categoryId=currentCategoryId type="list" limit="5" %}
                {% for item in categoryRelatedArchives %}
                    {# 排除当前文章本身 #}
                    {% if item.Id != currentArticleId %}
                        <li>
                            <a href="{{item.Link}}">{{item.Title}}</a>
                            <span>- {{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                        </li>
                    {% endif %}
                {% empty %}
                    <li>暂无同分类文章。</li>
                {% endfor %}
            {% endarchiveList %}
        </ul>
    </div>

    {# 方式二:根据关键词智能推荐关联文章 #}
    <div class="related-by-keywords">
        <h4>关键词推荐</h4>
        <ul>
            {% archiveList keywordRelatedArchives with type="related" like="keywords" limit="5" %}
                {% for item in keywordRelatedArchives %}
                    {# 排除当前文章本身 #}
                    {% if item.Id != currentArticleId %}
                        <li>
                            <a href="{{item.Link}}">{{item.Title}}</a>
                            <span>- {{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                        </li>
                    {% endif %}
                {% empty %}
                    <li>暂无关键词相关文章。</li>
                {% endfor %}
            {% endarchiveList %}
        </ul>
    </div>

    {# 方式三:手动关联的文章 #}
    <div class="related-by-manual">
        <h4>精选推荐</h4>
        <ul>
            {% archiveList manualRelatedArchives with type="related" like="relation" limit="5" %}
                {% for item in manualRelatedArchives %}
                    {# 排除当前文章本身 #}
                    {% if item.Id != currentArticleId %}
                        <li>
                            <a href="{{item.Link}}">{{item.Title}}</a>
                            <span>- {{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                        </li>
                    {% endif %}
                {% empty %}
                    <li>暂无手动关联文章。</li>
                {% endfor %}
            {% endarchiveList %}
        </ul>
    </div>
</div>

In this example, we first obtained the current article'sIdandCategoryId. Then, we used the tag three timesarchiveListin different waystypeandlikeCombining parameters to retrieve associated articles under different logic. In each loop, we pass through{% if item.Id != currentArticleId %}Ensure that the currently reading article is not displayed repeatedly.{% empty %}The tag elegantly handles the situation where no related articles are found, enhancing user experience.

Operational suggestions to improve the effect of related articles

As an operations manager, merely implementing the call to related articles is not enough; we also need to think about how to maximize its effect.

Firstly, the display position of the related articles is crucial. Usually, they appear below the article content, in the sidebar, or at the end of the article, ensuring that users can naturally discover more related information after completing the current content reading.Secondly, the number of displays should be moderate, usually recommended to display 3 to 8 articles, to avoid information overload or insufficient information.The attractiveness of the title and thumbnail also directly affects the click-through rate, therefore ensure that the associated articles have high-quality cover images and concise, clear titles.

In addition, regularly reviewing and optimizing keywords and tags is a long-term mechanism to improve the accuracy of keyword recommendations.For manual association, it should be combined with data analysis to associate the key content of the performance **or the user conversion path to achieve** the operation effect.These flexible tools provided by AnQiCMS, combined with refined operational strategies, will become an indispensable part of your website's content ecosystem.


Frequently Asked Questions (FAQ)

Ask: Why are my related articles not displayed, or displayed inaccurately?Answer: There may be several reasons why related articles do not display or are inaccurate. First, please check if your template code is usingarchiveListtags and their parameters, especiallycategoryId/typeandlikeWait. Next, confirm whether the current article has related content, such as other articles in the same category, whether the keywords/tags are set correctly, or whether other content is manually associated with the article in the background.Furthermore, if you are usinglike="keywords"Pattern, make sure the keywords of the article are set sufficiently accurate and rich.If the problem still exists, it is recommended to check the AnQiCMS backend log to see if there is any relevant error information.

Ask: Can I display multiple types of related articles on a single page? For example, some are in the same category and some are based on keywords?Answer: Absolutely. As shown in the practical example in the article, you can call it multiple timesarchiveListTag, set different parameters each time (for example, one time setcategoryId, and another time settype="related"andlike="keywords"), to obtain and display the list of associated articles under different logic.This combination of use can provide users with more diverse recommendation content, further improving the efficiency of content discovery and user satisfaction.

Ask: Does AnQiCMS automatically exclude the article currently being read to avoid its repetition in the related article list?Answer: AnQiCMS'archiveListTags do not automatically exclude the current article when retrieving related content. As an operations person, you need to manually add logic in the template code to exclude the current article. This is usually done byforAdd conditional judgment inside the loop, for example{% if item.Id != currentArticleId %}of whichcurrentArticleIdIs the one you get througharchiveDetailThe current article ID obtained by the tag. This processing ensures the smoothness of user experience and avoids unnecessary repetition.