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

Calendar 👁️ 73

How to keep visitors immersed in your site after they have finished reading an exciting article and discover more interesting information?One of the answers is to intelligently display related documents. This can effectively improve user experience, extend the time users spend on the website, and for search engine optimization (SEO), it can also help spiders better crawl and understand the website structure through the construction of internal links, thereby improving the relevance of the content and the overall weight of the website.

In Anqi CMS, obtaining and displaying the related document list is not a complex matter.This is due to the flexible template tag system of the system, which allows us to convert technical information into practical content display in a very intuitive way.

Understand the association mechanism of Anqi CMS

Safe CMS considered the interconnection of content from the beginning of its design.It can understand the 'relevance' between content from multiple dimensions, such as through the classification of documents, keywords, or even the theme of the content itself.At the same time, the system also allows us to manually specify some associations, providing great flexibility for content operations.

We will mainly use it in templatesarchiveListThis powerful tag is used to call the document list and specify the relevant documents to be retrieved through itstypeparameters.

Core feature: usearchiveListtags to display relevant documents

The most direct way to display related documents at the bottom of the document detail page is to usearchiveListLabel, andtypethe parameter to"related". The system will intelligently filter out other documents closest to the current document based on the content, classification, and other factors.

We can place the code in this way:

<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, titled "You might also like:" Next,archiveListThe tag will try to get 5 articles related to the current document and store them inarchivesIn a variable. We useforLoop througharchivesTo generate a link for each article containing the title, thumbnail, and summary. If the system does not find any related documents,{% empty %}The content will be displayed, to avoid blank pages.

here,limit="5"The parameter controls the number of relevant documents displayed, you can adjust this number according to the page layout and content strategy.item.ThumbUsed to display the article thumbnail,item.Description|truncatechars:80Then it will截取the article introduction in the first 80 characters,ensuring the layout is tidy.

Deep customization: usinglikeParameters improve the accuracy of relevance

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

Match based on keywords:like="keywords"

If your documents are all set with detailed keywords (you can fill in the "Publish Document" interface in the background), then you can tell the system to prioritize matching related documents based on these keywords. Whenlikeis set to"keywords"When, the system will find other documents containing the same keywords as 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.

Manually associated dependencies:like="relation"

Sometimes, we may need a more precise, manually intervene in the "relevance".For example, a product page needs to be associated with a specific review article, or a summary article needs to link to several articles supporting core viewpoints.The Anqi CMS allows us to manually associate other documents in the background document editing interface. Whenlikeis set to"relation"then,archiveListOnly these manually associated documents will be displayed.

To use this feature, you need to find the "Other Parameters" section (usually expandable) while editing documents in the background, where there will be a "Related Documents" setting item, where you can add the documents you want to associate.

<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 advantage of this model is that it has a very high relevance, fully in line with the intentions of content operators.

Combined with classification, it further expands the relevance.

In addition to the above.type="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 getting the current document category ID, thenarchiveListfiltering tags by category ID:

”`twig {% archiveDetail currentArchiveId with name=“Id” %} {# Get the current document ID #} {% archiveDetail currentCategoryId with name=“CategoryId” %} {# Get the current document category ID #}

<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 }}</

Related articles

How to implement the links and title display of the previous and next document pages on the content detail page?

In website operation, the navigation function of the previous and next pages on the content detail page may seem trivial, but it has a significant impact on user experience and the SEO performance of the website.It not only guides users to continue browsing more related content, improving the depth and stay time of page visits, but also provides a clear page flow for search engine crawlers, helping to index and rank the website's content.For those who use AnQiCMS to manage content, achieving this function is very direct and efficient

2025-11-09

How to display the document Tag label on the front-end page and use it as an entry for content association?

In modern website operations, how to effectively organize and present content is not only related to user experience, but also a key aspect of Search Engine Optimization (SEO).AnQiCMS (AnQiCMS) provides a powerful and flexible Tag label feature, which not only helps you better manage website content but also serves as a convenient entry point for users to find related information, greatly enhancing the association of content and the interactivity of the website. ### Overview of Tag Labels in AnQi CMS The design philosophy of Tag labels in AnQi CMS is very open and flexible.They are different from the traditional classification system

2025-11-09

How to set a default thumbnail to ensure that documents without uploaded images also have a unified display?

When using AnQi CMS to manage website content, we often encounter such situations: some articles, products, or pages may not have uploaded exclusive thumbnails due to insufficient content or oversight.This not only makes the website page look unprofessional and inconsistent, but may also affect users' desire to click on the content.Luckyly, Anqi CMS provides a very practical feature that can solve this problem once and for all - that is, setting a default thumbnail to ensure that even documents that do not upload pictures separately can have a unified and beautiful display effect.Why is it necessary to set a default thumbnail

2025-11-09

How different thumbnail processing methods (aspect ratio scaling, padding, cropping) affect the display effect of images on the front-end?

In website operation, images play a vital role, especially in places like list pages and detail pages where thumbnails are displayed. They not only affect the beauty of the page but also directly relate to the click-through rate and reading experience of users.AnQiCMS (AnQiCMS) offers various flexible thumbnail processing methods to help users meet the needs of image display in different scenarios.Understanding how these methods - scaling, padding, and cropping - affect the final presentation of images on the front end is particularly important for optimizing the visual experience of a website.Why is thumbnail processing so crucial

2025-11-09

How to flexibly call and display custom fields in front-end templates?

When using AnQi CMS to manage website content, its powerful content model and custom field features provide great flexibility for the personalized needs of the website.At times, we not only need to publish regular article titles, content, etc., but also need to add some unique information for specific types of articles or products, such as the author of the article, product model, launch date, and special selling points.This information is implemented through the content model custom fields.How can I flexibly call and display these custom fields in a website front-end template?This is the issue we are going to delve into today.

2025-11-09

How to use the `archiveFilters` tag to implement dynamic display of a multi-condition filter list?

How can we make it quick for users to find the information they need on the website, which is a key factor in improving user experience and conversion rate.When a website contains a variety of content, and each type of content has multiple attributes to choose from, providing a flexible multi-condition filtering function becomes particularly important.AnQiCMS provides a powerful `archiveFilters` tag that can help us easily implement dynamic filtering of content lists, making your website content come to life.Why do we need multi-condition filtering? Imagine that you are browsing a real estate website

2025-11-09

How does Anqi CMS implement highly customized display of the website front-end page?

How to implement high-level custom display of the website front-end page in AnqiCMS? Want to create a unique and powerful website? The key is to have a flexible grasp of the front-end page.AnqiCMS fully understands this, it not only provides an efficient and stable background management, but also endows users with extremely high customization capabilities on the front end.This is due to its exquisite template design, flexible content organization, and rich tag system, allowing users to build and present websites according to their own imagination.### One, Flexible Template System

2025-11-09

How to use the flexible content model of Anqi CMS to display diverse content structures?

In this era where content is king, the content of websites is no longer limited to simple articles and news.From e-commerce products to event information, from customer cases to job positions, each type of content has its unique structure and display requirements.If a content management system (CMS) can only use a single "article" template to carry all information, it will undoubtedly bring great difficulties to operation, not only making content management efficiency low, but also making the front-end display monotonous, difficult to attract users.

2025-11-09