How to display a list of recommended articles related to the current article content, supporting keyword search or manual association?

As an experienced security CMS website operations personnel, I fully understand the importance of high-quality content and accurate recommendations for improving user experience and website SEO.In the article detail page, effectively display recommended articles related to the current content, which can not only extend the user's visit time and reduce the bounce rate, but also optimize and improve the page weight and crawling efficiency through internal links.AnQi CMS provides flexible tags, supporting us to build this recommendation list through keywords or manual methods.

Implementing related article recommendations in Anqi CMS

AnQi CMS enables powerful template tag systems, especiallyarchiveListtags, providing us with a powerful tool for implementing related article recommendations. In the article detail page, we can usetype="related"Parameters to call the recommendation list related to the current article content. This tag has the ability to automatically associate with intelligence, and also supports our fine-grained manual control.

Article recommendations based on keyword association

By default, when we use the article detail pagearchiveListtags and settype="related"At the moment, Anqicms will intelligently capture and recommend other articles closest in content to the current article based on its category, tags, and content similarity.This approach is particularly efficient for websites with a large amount of content and similar article topics, as it can automatically complete most of the association work, greatly reducing the burden of manual maintenance.

If we need to use keywords more accurately for automatic association, we canarchiveListSpecify further in the taglike="keywords"Parameters. This means that the system will match other articles' keywords based on the current article's keywords, thereby filtering out more relevant recommended content.This method requires us to ensure the accuracy and richness of keywords when publishing articles, so that the automatic recommendation effect will be better.For example, if the current article discusses “AnQi CMS template creation”, the system will recommend articles containing keywords such as “template creation”, “AnQi CMS development”, and so on.

Manually associate recommended articles to enhance control

In addition to automatic association, Anqi CMS also provides the option to manually associate recommended articles, which means that our operation personnel have greater control over the recommended content.When there is a strong correlation between certain specific articles, or when we want to promote certain specific content, manual association becomes particularly important.

To manually associate, we need toarchiveListSet in the labeltype="related"while also increasinglike="relation"The parameter tells the system to read the list of preset related documents in the article background editing interface.In the Anqi CMS backend, when we edit a document, we are usually able to find a field in the 'Other Parameters' or a dedicated 'Related Documents' settings area that allows us to manually select or enter other articles associated with the current article.By precisely configuring these manually associated article IDs or titles, we can ensure that the content we want users to see is displayed on the article detail page, whether it is a series of articles, important announcements, or promotional products.

The following is an example of code that displays a list of related articles in an Anqi CMS template, which combines the logic of keyword automatic association and manual association:

{# 假设这是文章详情页,archive变量已包含当前文章数据 #}

<section class="related-articles">
    <h2>相关推荐</h2>
    <ul>
        {# 尝试首先通过手动关联来获取推荐文章,如果后台有设置 #}
        {% archiveList manualRelations with type="related" like="relation" limit="5" %}
            {% for item in manualRelations %}
                <li>
                    <a href="{{ item.Link }}">
                        {% if item.Thumb %}<img src="{{ item.Thumb }}" alt="{{ item.Title }}"/>{% endif %}
                        <h3>{{ item.Title }}</h3>
                        <p>{{ item.Description|truncatechars:80 }}</p>
                    </a>
                </li>
            {% endfor %}
        {% endarchiveList %}

        {# 如果手动关联文章不足或没有设置,则通过关键词自动获取 #}
        {% archiveList keywordRelations with type="related" like="keywords" limit="5" %}
            {% for item in keywordRelations %}
                <li>
                    <a href="{{ item.Link }}">
                        {% if item.Thumb %}<img src="{{ item.Thumb }}" alt="{{ item.Title }}"/>{% endif %}
                        <h3>{{ item.Title }}</h3>
                        <p>{{ item.Description|truncatechars:80 }}</p>
                    </a>
                </li>
            {% endfor %}
        {% endarchiveList %}

        {# 如果上述两种方式都未能提供足够内容,可以退而求其次,获取同分类最新文章 #}
        {% archiveList fallbackArticles with categoryId=archive.CategoryId type="list" order="id desc" limit="5" %}
            {% for item in fallbackArticles %}
                {# 排除当前文章本身 #}
                {% if item.Id != archive.Id %}
                    <li>
                        <a href="{{ item.Link }}">
                            {% if item.Thumb %}<img src="{{ item.Thumb }}" alt="{{ item.Title }}"/>{% endif %}
                            <h3>{{ item.Title }}</h3>
                            <p>{{ item.Description|truncatechars:80 }}</p>
                        </a>
                    </li>
                {% endif %}
            {% endfor %}
        {% endarchiveList %}
    </ul>
</section>

In the operation, reasonably using the relevant article recommendation list can significantly improve user activity on the website.It is recommended that we prioritize manual association to ensure the exposure of core content, and then use keyword automatic association to cover a wider range of related topics.At the same time, regularly reviewing the effectiveness of recommendations and adjusting the association strategy based on user behavior data will help to continuously optimize the user experience and the effectiveness of content marketing.

Frequently Asked Questions (FAQ)

Why is my related article list not displaying any content?

If the related article list is empty, first check if the current article is on the detail page (archiveDetailcontext) becausetype="related"The tag only takes effect on this type of page. Next, confirm whether the article has been published and is visible. If usinglike="keywords",please check if the article has set keywords; if usinglike="relation"Please confirm whether other articles have been manually associated in the background article editing page. Finally, ensure that the spelling and parameter settings of the template tags are correct.

Can I mix the automatic association of keywords with manual association?

Yes, you can mix and match. In the template, you can first try to associate articles manually, and if the number is insufficient, supplement them through keyword automatic association.As shown in the code example above, by nesting or conditional judgment, you can flexibly control the priority and source of recommended content to achieve **user experience and operation goals.

What is the sorting logic of related articles? Can I control its sorting?

When usingtype="related"When, the default sorting logic is based on the system's intelligent judgment of relevance. However,archiveListThe tag itself supportsorderparameters, for exampleorder="views desc"(in descending order of views) ororder="id desc"(in descending order of publication time). You can try to adjust theorderThe parameter withtype="related"Combine usage, but please note that for certain types of relevance calculations (such aslike="relation"Or the default nearest document), the sorting effect may be limited by the internal logic. **In practice, the system first filters based on relevance and then applies your sorting preferences on this basis.