How to retrieve and display a list of related documents based on the current document, to enhance content relevance?

How can visitors continue to immerse themselves in your site and find more interesting information after browsing an excellent article?The answer is that documents should be displayed intelligently.This not only effectively improves user experience and extends the time users spend on the website, but also helps search engine optimization (SEO) by building internal links, enabling spiders to better crawl and understand the website structure, thereby improving the relevance of the content and the overall weight of the website.

In the Auto CMS, obtaining and displaying the list of related documents is not a complex task.This is due to the flexible template tag system of the system, which allows us to present technical information in a very intuitive way, converting it into practical content display.

Understanding the association mechanism of Anqi CMS

The Aiqi CMS was designed with the consideration of content interconnectivity from the beginning.It can understand the "relevance" between content from multiple dimensions, such as document categorization, keywords, and even the thematic content itself.At the same time, the system also allows us to manually specify some associations, providing great flexibility for content operations.

In the template, we mainly usearchiveListthis powerful tag to call the document list, and specify through thetypeparameters what we want to get is "related documents".

Core Function: UsearchiveListLabel display related documents

The most direct way to display related documents at the bottom of the document detail page is to usearchiveListtags, andtypeparameter settings"related"。The system will intelligently select the closest other documents to the current document based on the content, category, and other factors, automatically.

We can place the code like this:

<section class="related-articles">
    <h3>你可能还会喜欢:</h3>
    {% archiveList archives with type="related" limit="5" %}
        {% for item in archives %}
        <article class="related-item">
            <a href="{{ item.Link }}">
                {% if item.Thumb %}
                <img src="{{ item.Thumb }}" alt="{{ item.Title }}" class="related-thumb">
                {% endif %}
                <h4 class="related-title">{{ item.Title }}</h4>
            </a>
            <p class="related-description">{{ item.Description|truncatechars:80 }}</p>
        </article>
        {% empty %}
        <p>目前没有找到与当前内容相关的推荐文档。</p>
        {% endfor %}
    {% endarchiveList %}
</section>

This code first declares asection,Title is "You might also like:". Next,archiveListTags will try to get 5 articles related to the current document and store them inarchivesvariables. We useforto iteratearchivesEnglish translation: For each article, generate a link that includes the title, thumbnail, and summary. If the system does not find any related documents,{% empty %}The content will be displayed partially, to avoid blank pages on the page.

Here,limit="5"The parameter controls the number of relevant documents displayed, and you can adjust this number according to the page layout and content strategy.item.ThumbUsed to display the article thumbnail,item.Description|truncatechars:80It will截取文章简介的前80个字符,ensure the layout is neat.

Deep customization: uselikeParameters to improve relevance accuracy

In addition to the system automatically determining relevance, the Anqi CMS also provideslikeparameters, allowing us to control the matching logic of relevant documents more finely. This parameter is particularly useful whentype="related"used.

Based on keywords for matching:like="keywords"

If your documents are all set with detailed keywords (you can fill in the keywords on the "Publish Document" interface in the background), then you can tell the system to prioritize matching relevant documents based on these keywords. Whenlikeset"keywords"When, the system will search for other documents containing the same keywords based on the first keyword of the current document.

<section class="keyword-related-articles">
    <h3>基于关键词的推荐:</h3>
    {% archiveList archives with type="related" like="keywords" limit="5" %}
        {% for item in archives %}
        <article class="related-item">
            <a href="{{ item.Link }}">
                <h4 class="related-title">{{ item.Title }}</h4>
            </a>
            <p class="related-description">{{ item.Description|truncatechars:80 }}</p>
        </article>
        {% empty %}
        <p>目前没有找到基于关键词的推荐文档。</p>
        {% endfor %}
    {% endarchiveList %}
</section>

This method is suitable for sites with highly segmented content and standardized keyword management.

Dependency manually associated:like="relation"

likeset"relation"whenarchiveListOnly these manually associated documents will be displayed.

To use this feature, you need to edit the document in the background and find the 'Other Parameters' section (usually expanded), where there will be a 'Related Documents' setting item. You can add the documents you wish to associate there.

<section class="manual-related-articles">
    <h3>编辑精选推荐:</h3>
    {% archiveList archives with type="related" like="relation" limit="5" %}
        {% for item in archives %}
        <article class="related-item">
            <a href="{{ item.Link }}">
                <h4 class="related-title">{{ item.Title }}</h4>
            </a>
            <p class="related-description">{{ item.Description|truncatechars:80 }}</p>
        </article>
        {% empty %}
        <p>目前没有编辑精选的推荐文档。</p>
        {% endfor %}
    {% endarchiveList %}
</section>

The advantages of this model are extremely high relevance, fully in line with the intentions of content operators.

Further expand relevance by combining categories.

In addition to the abovetype="related"The usage, we can also combine categories to get relevant documents.For example, when reading an article about 'Anqi CMS template creation', we may want to see other articles in the same category.

This can be achieved by obtaining the current document's category ID, thenarchiveListfiltering tags by category ID:

English

<h3>同分类最新文档:</h3>
{% archiveList archives with type="list" categoryId=currentCategoryId excludeCategoryId=currentArchiveId order="id desc" limit="5" %}
    {% for item in archives %}
    <article class="related-item">
        <a href="{{ item.Link }}">
            <h4 class="related-title">{{ item.Title }}</h4>
        </a>
        <p class="related-description">{{ item.Description|truncatechars:80 }}</