How does the `relatedArchive` tag display a list of related articles based on document relevance?

Calendar 👁️ 67

In the daily operation of a website, how to make users naturally discover more interesting content after reading an article is the key to improving user experience, extending the time spent on the website, and even optimizing SEO effects. Anqi CMS understands this point and provides powerful template tag functions, among whichrelatedArchiveTags are the tools used for intelligent display of related article lists.

relatedArchiveTags: Make your related article list smarter

relatedArchiveThe charm of tags lies in their ability to automatically or according to the rules we specify, recommend a series of articles highly relevant to the content being viewed.This can effectively guide users to perform in-depth reading, build high-quality internal links within the site, and significantly reduce the bounce rate of the website, making visitors stay longer on your site.

It should be clarified that,relatedArchiveIt is not an independent tag name, it is actuallyarchiveList(Document list) A special usage of the tag, by addingtype="related"Parameters to activate the intelligent recommendation function for related articles. This tag is most commonly used on article or product detail pages because the logic of relevance requires a "current document" as a reference.

How does AnQi CMS determine the 'relevance' of an article?

The Anqi CMS provides flexible logic when handling "related articles", allowing you to choose the most suitable strategy based on your actual needs:

First, when you do not specify the association method additionally,relatedArchiveit will usethe default association logic. It will intelligently search for articles that are "close" to the current document ID in the same category.This 'closeness' usually refers to documents that are close in terms of publication time or ID sequence, which ensures that the recommended articles remain consistent with the current category theme.

Secondly, if you want to emphasize the relevance of the content theme, you can use the keywords of the article for matching. By settinglike="keywords"parameter,relatedArchiveIt will prioritize based on the current document'sfirst keywordTo get related documents. This means that if you set accurate keywords for articles in the background, the system can recommend content with similar themes more accurately.

Finally, for those who needHighly precise control of related contentThe scenario, AnQi CMS provides the option to manually set.You can manually specify 'related documents' for each article in the document editing interface of the background.At this time, just set in the taglike="relation"The system will display the list of related articles completely according to your manual configuration, which is particularly useful for scenarios where you need to emphasize specific content or carry out thematic promotion.

How to use in the templaterelatedArchiveTag?

Use in your article detail page template,relatedArchiveThe label is very intuitive. Here is a typical code example that shows how to retrieve and loop through the titles, links, and thumbnails of up to 10 related articles:

{# related 相关文档列表展示 #}
<div class="related-articles-section">
    <h3>相关推荐</h3>
    <ul>
    {% archiveList archives with type="related" limit="10" %}
        {% for item in archives %}
        <li>
            <a href="{{item.Link}}">
                {% if item.Thumb %}
                <img alt="{{item.Title}}" src="{{item.Thumb}}">
                {% endif %}
                <h5>{{item.Title}}</h5>
                <p>{{item.Description|truncatechars:80}}</p> {# 截取描述前80个字符 #}
            </a>
        </li>
        {% empty %}
        <li>
            抱歉,当前没有找到相关文章。
        </li>
        {% endfor %}
    {% endarchiveList %}
    </ul>
</div>

In this example:

  • {% archiveList archives with type="related" limit="10" %}This line of code tells Anqi CMS that we want to get a list of documents and that the type of this list is "related documents" (type="related"), showing a maximum of 10 articles (limit="10")
  • {% for item in archives %}: Due torelatedArchiveIt returns a list of articles, we need to usefora loop to iterate over each article.itemis the current article object in the loop.
  • {{item.Link}}/{{item.Title}}/{{item.Thumb}}/{{item.Description}}These are the common properties of the current article object, you can call them as needed, such as article link, title, thumbnail, and description.truncatechars:80The filter can ensure that the description will not be too long.
  • {% empty %}: This is a very practicalforLoop auxiliary tag, whenarchivesThe list is empty, that is, no related articles are found, it will displayemptyThe content in the block, to avoid blank pages.

Master the key parameters

To better control the display of relevant articles, it is crucial to understand the following parameters:

  • type="related"This is the core parameter for activating the relevant article function.
  • limit="数字"Used to control the maximum number of related articles displayed, for examplelimit="5"Only 5 articles will be displayed.
  • like="keywords"Used when you want to associate articles based on keywords.
  • like="relation": When you want to use the related articles manually set in the background.

It is worth noting that whentypeThe value isrelatedthen,order(Sorting) Parameters will not be supported. The system will sort according to its internal association logic to ensure the relevance of recommendations.

By flexible applicationrelatedArchiveTags and the various associated logic they provide will enable you to offer your website visitors more intelligent and personalized content recommendations, greatly enhancing user stickiness and the overall value of the website.


Frequently Asked Questions (FAQ)

1. Why did I setrelatedArchivethe tag, but the related article list is empty?

There may be several reasons for this situation:

  • Not the document detail page: relatedArchiveThe label must work on the document (article/product) detail page because it needs a 'current document' as a reference. If used on other pages, the list may be empty.
  • There are no adjacent or matching documents:If you are using the default association (not specifiedlikeparameter), there may not be enough "adjacent" documents in the current category. If you have usedlike="keywords"It is possible that the keywords of the current document do not match any in other articles.
  • Not manually associated:If you have set uplike="relation"But forgot to manually associate related articles in the background document editing interface, the list will naturally be empty.

2.relatedArchiveTags vs normalarchiveListWhat's the difference between tags?

relatedArchiveis a tagarchiveListA specific application scenario of the tag, the main difference being:

  • Different purposes: relatedArchiveUsed specifically for 'recommend articles related to the current document', the core being the intelligent or manual establishment of associations.archiveListIt is a more general tag that can be used to retrieve lists of any type of articles (such as the latest articles, popular articles, articles of specified categories, etc.), and it requires you to manually specify various filtering and sorting conditions.
  • Mechanism: relatedArchiveWhile working, it will automatically take the current document as the center to find related documents (same category nearby, keyword matching, or manually specified).archiveListIt will be completely based on the one you pass in.categoryId/order/flagFilter and sort by parameters.
  • Parameter limitations: relatedArchive(i.e.),archiveListwithtype="related"Not supported when used together)orderParameter, as it has its own associated sorting logic.

3. Can I use keyword association and manual association at the same time? Which one will take effect if both are set?

InrelatedArchiveTagged,likeThe parameter can only specify one value, namelylike="keywords"orlike="relation". If you try to set at the same time or the system detects a conflict, there is usually a priority or only one takes effect (for specific behavior, please refer to the latest document description of AnQi CMS or actual test).To avoid confusion, it is recommended that you clearly choose a related logic according to your actual needs to ensure that the display of the related article list meets your expectations.

Related articles

How to display the link to the previous and next documents on the AnQiCMS document detail page?

In the ocean of website content, users often hope to browse related information smoothly, not wanting to return to the list to find the next article after reading a wonderful article.This not only affects user experience, but also benefits the internal link structure of the website and search engine optimization (SEO) a lot.AnQiCMS has fully considered this point, providing a convenient and quick navigation function for the content detail page, allowing users to easily navigate between different documents.The AnQiCMS template system is very flexible, it adopts the syntax of the Django template engine

2025-11-07

How to retrieve and display the complete content and properties of a single document using the `archiveDetail` tag?

When using AnQiCMS to build website content, displaying the complete information of a single document is one of the core requirements.No matter whether it is the detailed content of an article, a detailed introduction of a product, or any other specific entry of a custom content model, a highly efficient and flexible way is needed to extract and present this data.This is where the `archiveDetail` tag comes into play.

2025-11-07

How to add pagination and optimize the display effect for document lists in AnQiCMS?

In website operation, how to efficiently display a large amount of content while ensuring the smoothness of user experience is a topic that cannot be ignored.The pagination feature of the document list is the key to solving this problem.AnQiCMS (AnQiCMS) is an efficient and flexible content management system that provides intuitive and powerful template tags, allowing you to easily add pagination features to document lists and optimize the display on top of that, making your website content more attractive.

2025-11-07

How to filter and display the document list of a specified category or model with the `archiveList` tag in AnQiCMS?

AnQiCMS as an efficient enterprise-level content management system, provides users with flexible and diverse content management and display capabilities.When building a website, we often need to display document lists based on specific conditions, such as only showing articles in a particular category, or only listing entries of specific content models (such as products, services).At this time, the `archiveList` tag has become a powerful tool in our hands.It is not only powerful but also very intuitive to use, making it easy for us to meet these needs.### `archiveList`

2025-11-07

How does the AnQiCMS `categoryList` tag display hierarchical category structures and show category information?

In AnQi CMS, website categories are the foundation for organizing content. Whether it's articles, products, or other custom models, a clear category structure can greatly enhance user experience and the website's SEO effectiveness.The Anqi CMS provides a powerful `categoryList` tag, allowing us to flexibly display single or multi-level classification structures and easily obtain detailed information about each classification.### Master the basic usage of the `categoryList` tag To display the category list, we first need to use the `categoryList` tag

2025-11-07

How to retrieve and display detailed information such as description, Logo, etc. for a specific category using the `categoryDetail` tag?

In AnQiCMS template development, obtaining and displaying detailed category information is a key step in building rich and user-friendly pages.The `categoryDetail` tag was created for this purpose, it can help you easily retrieve the description, Logo, custom fields, and other detailed content of a specific category at any location on the page.### `categoryDetail` tag's core function The main function of the `categoryDetail` tag is to obtain detailed data of a single category

2025-11-07

How does the `pageList` tag display all the titles and links of the individual pages of the website?

In Anqi CMS, using the `pageList` tag to display the titles and links of all single pages is a very common and practical need in website layout and navigation settings.Whether it is used for website footer navigation, sidebar link list, or building a simple HTML site map, the `pageList` tag can help us efficiently achieve these functions. ### Understanding AnQi CMS Single Page Firstly, let's briefly review the "single page" in AnQi CMS.In the Anqi CMS backend management, there is a special "Page Resources" module

2025-11-07

How does the `pageDetail` tag display the detailed content of a single page, such as the 'About Us' page?

In Anqi CMS, single pages (such as "About UsTo present the detailed content of these single pages on the website frontend, we will use a very core and practical template tag——`pageDetail`.This tag helps us accurately extract and display various information on a specified single page, ensuring the flexibility and accuracy of content presentation.

2025-11-07