How to display a list of related documents on the document detail page, such as categorized recommendations or keyword-based recommendations?

Calendar 78

In website content operation, providing more relevant and potentially interesting content to visitors is a key strategy to improve user experience, extend website stay time, and promote in-depth content browsing.This not only effectively guides users to explore more information, but is also an important component of "page interconnectivity" in Search Engine Optimization (SEO).In such a powerful content management system as AnQiCMS, it is flexible and efficient to implement the display of related document lists on the document detail page.

Anqi CMS provides for usarchiveListSuch a core template tag, it can meet the needs of various document list calls, including displaying related content on the document detail page.We can build these lists based on different logic, such as categorized recommendations, keyword recommendations, or even manual associations.

UtilizearchiveListLabel implementation related document recommendation

To implement the display of related document lists on the document detail page, we mainly use AnQiCMS'sarchiveListTemplate tag. This tag is feature-rich, and through itstypeandlikecombination of parameters, it can easily achieve various recommendation logic. Usually, this code is placed in the corresponding content model of yourdetail.htmlIn a template file, for example, the detail page template of an article model might bearticle/detail.html.

Let's discuss several common implementation methods one by one:

1. Smart classification recommendation (based on classification and similarity)

This is the most common and basic recommendation method, that is, recommend other related documents under the category of the current document. AnQiCMS defaulttype="related"The pattern can complete this task well. It will intelligently search for other nearby documents in the same category as the current document, providing natural extension reading.

Place the following code snippet in your document detail page template, for example, below the main content area:

<div class="related-documents">
    <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="document-thumb">
                {% endif %}
                <span class="document-title">{{ item.Title }}</span>
                <span class="document-date">{{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
            </a>
        </li>
        {% empty %}
        <li>暂无相关推荐文档。</li>
        {% endfor %}
    {% endarchiveList %}
    </ul>
</div>

In this code block:

  • {% archiveList archives with type="related" limit="5" %}We calledarchiveListTag, assign the obtained document list toarchivesVariable.type="related"Tell the system to retrieve the list related to the current document,limit="5"which limits the display quantity to 5 items.
  • {% for item in archives %}: This is a loop structure that will iterate overarchiveseach document in the list.
  • {{ item.Link }}/{{ item.Title }}:itemRepresents the current looped document object, we can access.the operator to access its various properties, such as links (Link), Title (Title).
  • {% if item.Thumb %}: Here, it checks if the document has a thumbnail (Thumb), if any, is displayed. Thumbnails make the recommendation list more attractive.
  • {{ stampToDate(item.CreatedTime, "2006-01-02") }}:stampToDateIs the time formatting function provided by AnQiCMS, which can convert timestamps into readable date formats.
  • {% empty %}: It is a very practical tag, whenarchivesWhen the list is empty (i.e., no related documents are found), it will display<li>暂无相关推荐文档。</li>To avoid blank pages or errors on the page."),

In this way, AnQiCMS will automatically filter out the most likely content that users are interested in based on the classification information of the current document, greatly reducing the maintenance cost of content operation.

2. Precise Keyword Recommendation

If your website content is very dependent on keywords to organize, or you want to recommend content strongly related to the core keywords of the current document, then you can uselike="keywords"Parameters. This requires you to manage keywords carefully when publishing documents.

Modify the code in the above.archiveListAdd tags, join.like="keywords":

<div class="keyword-related-documents">
    <h3>基于关键词推荐</h3>
    <ul>
    {% archiveList archives with type="related" like="keywords" limit="5" %}
        {% for item in archives %}
        <li>
            <a href="{{ item.Link }}" title="{{ item.Title }}">
                {% if item.Logo %} {# 也可以使用 Logo 字段作为图片 #}
                <img src="{{ item.Logo }}" alt="{{ item.Title }}" class="document-logo">
                {% endif %}
                <span class="document-title">{{ item.Title }}</span>
                <span class="document-description">{{ item.Description|truncatechars:50 }}</span> {# 截取部分描述 #}
            </a>
        </li>
        {% empty %}
        <li>暂无基于关键词的推荐文档。</li>
        {% endfor %}
    {% endarchiveList %}
    </ul>
</div>

We used herelike="keywords"The system will analyze the keywords of the current document and use them to find other documents containing the same keywords.{{ item.Description|truncatechars:50 }}Then a filter was used.truncatecharsExtract the first 50 characters of the document description to prevent the content from being too long and affecting the layout.

To ensure the effectiveness of keyword recommendations, you need to make sure that you have filled in relevant and accurate keywords for each document when publishing documents in the background "Content Management" -> "Publish Documents". Keyword library management function (help-plugin-rewrite.mdThe "keyword library management" mentioned here plays an important role in helping you maintain a set of standardized keyword systems.

3. Manually selected related recommendations

In certain specific scenarios, you may want to have the decision of which documents are related made entirely by humans, such as the next article in a series or supplementary materials for a product.The AnQiCMS backend document editing interface allows you to manually set 'related documents'. At this time,like="relation"Parameters can be put to good use.

toarchiveListlabel'slikethe parameter to"relation":

<div class="manual-related-documents">
    <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="document-title">{{ item.Title }}</span>
                <span class="document-views">阅读量: {{ item.Views }}</span>
            </a>
        </li>
        {% empty %}
        <li>暂无手动精选的推荐文档。</li>
        {% endfor %}
    {% endarchiveList %}
    </ul>
</div>

When you chooselike="relation"At that time, the system will only display those related documents that have been manually selected or filled in by the operator on the background editing page of the current document.This method provides the highest degree of control, ensuring that the recommended content conforms to the operator's precise intention.

Summary of implementation steps

  1. Determine the recommendation strategy:Firstly, based on your content type and operational objectives, choose the most suitable recommendation method (category intelligent recommendation, keyword recommendation, or manual selection).
  2. Locate the template file:Log in to the AnQiCMS admin panel, navigate to 'Template Design' -> 'Template Management'.Find the detail page template file you need to add related document list.usually its path is similar/template/{你的模板目录}/{内容模型表名}/detail.html.
  3. Insert the code:Paste the corresponding code snippet into the appropriate location in the template file, such as at the bottom of the main content area or in the sidebar.
  4. Save and test:Save the template file and access the corresponding document detail page on the front end to check if the document list is displayed correctly.If you find any layout issues, you can adjust them by modifying the CSS styles.

By flexible applicationarchiveListDifferent parameters of tags, we can easily create various forms of related document recommendation functions in AnQiCMS, thereby significantly improving the interactivity of website content and the depth of users' browsing.


Frequently Asked Questions (FAQ)

1. Why did I configure the related document list, but no content is displayed on the page?

When encountering this situation, the following aspects need to be checked first:

  • Is the document data sufficient?Make sure your website has enough documentation and that there are classifications, keywords, or manual associations between them. For example, if you usetype="related"Perform category recommendations, but since your category only has one document (i.e., this one), it is naturally impossible to recommend other documents.
  • Is the parameter setting correct:Check carefullyarchiveListLabel parameters, such astype="related"/like="keywords"orlike="relation"Make sure the spelling is correct. EspeciallylimitIf the parameter is set too small, it may cause even with relevant documents, it may not be displayed in full.
  • Content integrity:If it islike="keywords"Pattern, please check if the current document is filled with keywords and if other documents also contain these keywords. If it islike="relation"Please confirm whether other documents were manually associated when editing the current document in the background.
  • Template caching issue: AnQiCMS has

Related articles

How to display the link and title of the previous and next article in AnQiCMS template?

It is crucial to provide visitors with a smooth navigation experience in website operation.When a user finishes reading an article, they naturally expect to find more related content, and the "Previous" and "Next" links are the key features to meet this need.They can not only improve the user's stay time on your website, but also have a positive impact on search engine optimization (SEO) by building an internal link structure.AnQiCMS provides concise and efficient built-in tags for template developers, allowing you to easily display links and titles of the previous and next articles on the article detail page.

2025-11-08

How to implement filtering in the article list based on custom parameters (such as product features, price range)?

In website operation, we often need to classify and filter content lists more finely to help users quickly find the information they are really interested in.Traditional article classification can solve most problems, but when the content attributes become more complex, such as products with multiple characteristics, price ranges, or events with different themes and participation methods, a single classification seems to be inadequate.

2025-11-08

How to implement a search function on the front end of a website and display a list of search results with highlighted keywords?

When building a rich website, providing an efficient and convenient search function is a key aspect of improving user experience.AnQiCMS (AnQiCMS) has fully considered this from the beginning of its design, through its flexible template engine and built-in tags, we can relatively easily implement search functionality on the website front-end, and further optimize it to make the keywords in the search results stand out and highlight prominently.### Core Mechanism: Understanding the Search Principle of AnQiCMS The core of AnQiCMS website frontend search lies in `search/index.html`

2025-11-08

How to implement content pagination display and customize page navigation style in AnQiCMS template?

As the content of the website becomes richer, how to efficiently display a large amount of information while ensuring a user-friendly browsing experience is an indispensable link in website operation.In AnQiCMS, through the powerful template tag system, we can easily achieve content pagination display and flexibly customize the style of page navigation, making the website content both rich and tidy.--- ### Efficient Content Organization: Implementing Pagination of Content Lists In the AnQiCMS template, the core of implementing content pagination is to use the `archiveList` tag to retrieve document lists

2025-11-08

How to perform simple arithmetic operations such as addition, subtraction, multiplication, and division in AnQiCMS templates?

When creating templates in AnQiCMS, we often need to perform some simple numerical calculations, such as displaying the total price of goods, calculating the percentage of article reading volume, or handling the serial numbers in the list.AnQiCMS is a powerful template engine that supports direct arithmetic operations such as addition, subtraction, multiplication, and division in templates, making our content display more flexible and dynamic.

2025-11-08

How to use the filter (filter) to truncate, convert case, or escape HTML in displayed text?

When building a website, we often need to process various text content displayed on the page, such as limiting the length of article abstracts, unifying the case format of user input, or ensuring that user submitted content can be safely displayed on the page without destroying the page structure.AnQiCMS (AnQiCMS) provides us with powerful template filter functions, which can efficiently and conveniently complete these tasks.The filter is a very practical tool in the Anqi CMS template, which helps us quickly process and format the data displayed on the page.

2025-11-08

How to display a preset default value (such as "No data") for empty variables in the template?

In website operation, the completeness of content display and user experience is crucial.When we call data in AnQiCMS (AnQiCMS) template, we sometimes encounter the situation where some variables are empty.If these empty variables are not processed, the front-end page may appear blank areas, 'null' text, and even cause layout disorder, thus affecting the professionalism of the website and the user's browsing experience.

2025-11-08

How to convert multi-line text (including newline characters) in a template to an HTML paragraph or `<br/>` tag for display?

In website content operation, we often encounter such situations: the background text input box allows users to enter multiple lines of text, such as article summaries, product descriptions, contact addresses, and so on.When these multi-line text containing line breaks are displayed in a website front-end template, if output directly, we will find that the original line breaks do not take effect, and all the text is squeezed into one line.This is because the browser defaults to merging consecutive whitespace characters (including newline characters) into a single space.

2025-11-08