How to use the `tagList` tag to display the associated tag list on the article detail page?

Calendar 👁️ 79

In content operation, tags (Tags) are a very practical tool that can help us organize content more flexibly, making it convenient for readers to quickly find related topics of interest.Imagine that after a user finishes reading an exciting article, if they can immediately see other popular topics or keywords related to the article, it will undoubtedly greatly enhance their browsing experience and encourage them to explore other content on the website.tagListTag it to complete.

Why should associated tags be displayed on the article detail page?

Displaying related tags on the article detail page not only improves the navigation experience for users, but also brings various benefits to the website.Firstly, from the user's perspective, these tags are the 'index' of the content, they can click on the tags and easily jump to other articles under the same theme, thereby extending the website's stay time.Secondly, for search engine optimization (SEO), using tags properly helps search engines better understand the article topic, crawl and index relevant content, thereby improving the visibility of the website in search results.Moreover, it also helps with content discovery, ensuring that your high-quality content is not buried and forms a rich internal link structure on your website.

Know about AnQi CMStagListTag

The template system of AnQi CMS is very flexible, the core of which is its rich tag library.tagListIt is one of the tags specifically used to retrieve the list of document tags.Its design初衷 is to facilitate developers and content operators to quickly display related tags on articles, product details pages, and other pages.On usage, it is very easy to get started, similar to the Django template engine syntax.

In the article detail page,tagListTags do not require special configuration to intelligently recognize the ID of the article currently being viewed and automatically extract all tags associated with the article.These tags are usually returned in an array format, which is convenient for us to display through loops in the template.

How to add related tag lists on the article detail page?

To display related tags on the article detail page of your Anqi CMS website, simply add a few lines of simple code to the corresponding template file. Below is a practical code snippet and step-by-step instructions:

{# 在文章详情页中,tagList标签会默认读取当前文章的ID来获取标签 #}
{% tagList tags %}
    {% if tags %} {# 检查是否有标签,避免在没有标签时显示空区域 #}
        <div class="article-tags">
            <strong>相关标签:</strong>
            {% for item in tags %}
                <a href="{{ item.Link }}" title="{{ item.Title }}">{{ item.Title }}</a>
            {% endfor %}
        </div>
    {% endif %}
{% endtagList %}

This code will traverse all the associated tags of the current article and generate a clickable link for each tag.item.LinkIt will automatically direct to the detail page of the tag, anditem.TitleThe label's display name. This way, when the reader clicks on the label, they can see a list of all articles containing that label.

Deployment steps:

In practice, adding the associated tag list to the article detail page is very simple:

  1. Confirm the template file:Open the folder of the template used by your current site. The template file for the article detail page is usually located in{模型table}/detail.htmlFor example, if your article model isarticle, then the file path may betemplate/您的模板名称/article/detail.html.
  2. Select a suitable location:Find the position after the article content display area, before the related recommendations or comments section, which is the ideal area for displaying tags in the template file.
  3. Insert the code:Take the provided abovetagListCopy and paste the code snippet to the selected location.
  4. Save and update:Save template file.If you are developing locally, refresh your article detail page to see the effect.If operating in an online environment, you usually need to log in to the Anqi CMS backend, click the "Update Cache" feature to ensure that the latest template files take effect.

Optimize label display:

tagListThe label also provides some parameters that allow you to control the display of the label more flexibly:

  • Limit the display quantity (limit):If you find that there are too many tags, which may affect the beauty of the page or the loading speed, you can uselimitParameters to limit the number of displayed tags. For example, display only the first 5 tags:
    
    {% tagList tags with limit="5" %}
        {# ... 标签循环代码 ... #}
    {% endtagList %}
    
  • Display all tags (itemId="0"):It should be noted that,tagListThe default is to display the tags of the current article. If you have some special requirements and want to display *all site tags* on the article detail page instead of the tags of the current article, you canitemIdthe parameter to0:
    
    {% tagList tags with itemId="0" limit="10" %}
        {# ... 标签循环代码 ... #}
    {% endtagList %}
    
    However, it is quite rare to display the entire site tags on the article detail page, usually we are more concerned with tags directly related to the current content.
  • Filter by category (categoryId):Assuming you only want to display tags under a specific category (even if these tags are also associated with the current article), you can alsocategoryIdParameter filtering. For example, only display tags associated with articles of category ID 1: “`twig {% tagList tags with categoryId=“1” limit=“10” %} {# … tag loop code

Related articles

How to display the category information of the articles on the front page of AnQi CMS, including the category name and link?

In Anqi CMS, the display of article category information on the front page is a key link in content organization and user navigation.Whether it is to help users understand the context of the article or to optimize the website's SEO structure, accurate and accessible category names and links play an important role.AnQi CMS with its flexible template engine makes this task intuitive and efficient.Understanding Anqi CMS's Classification System Before delving into the display methods, we first need to know that Anqi CMS's content management system attaches great importance to the concept of 'classification'.Each document (whether it is an article

2025-11-09

How to display the publication time of articles in Anqi CMS and customize the date and time format?

When operating website content, the publication time of the article is an indispensable element.It not only helps visitors quickly understand the "freshness" of the content, but also has a positive impact on search engine optimization (SEO), as it conveys the signal that the website content is continuously updated.AnQiCMS provides great flexibility in content management, whether it is to obtain or customize the display time of published articles, it is very convenient.Next, we will explore how to flexibly display the publication time of articles in Anqi CMS

2025-11-09

How to display the cover image (Logo) and thumbnail (Thumb) of an AnQi CMS article?

In content operation, the cover image (Logo) and thumbnail (Thumb) of the article play a crucial role. They not only attract readers' attention and increase click-through rates, but are also an indispensable part of search engine optimization (SEO).AnQiCMS (AnQiCMS) provides users with a flexible and convenient way to manage and display these visual elements.This article will discuss in detail how to configure and call the cover image and thumbnail of the article in AnQiCMS.## One, Configuration and generation of cover image and thumbnail In AnQiCMS

2025-11-09

How to generate the catalog navigation on the front page for the automatic extraction of article content (`ContentTitles`) feature?

In Anqi CMS, providing a clear directory navigation to help readers better understand the structure of long articles is the key to improving user experience.The Anqi CMS article content automatically extracts the title (ContentTitles) feature, which is for this purpose.It can intelligently identify the various titles in the article content and provide this structured information to the front-end template, making it easy for us to build a dynamic and practical directory navigation.###

2025-11-09

How to display custom fields (such as author, source) of AnQi CMS documents on the front-end page?

When managing content in Anqi CMS, we often encounter the need to add more personalized data to articles, products, or pages, such as the author of the article, the source of content, or specific parameters of products, or specific attributes of event pages, etc.This additional customization information is called "custom field".The powerful content model function of AnQi CMS makes it very convenient to create and manage custom fields, and more importantly, how to accurately and beautifully present these meticulously entered custom fields on the front page of the website

2025-11-09

How to build and display a multi-level product category navigation in AnQi CMS?

AnQi CMS is a powerful content management system that provides users with the ability to flexibly build and display multi-level product classification navigation.This not only helps website visitors easily find the products they need, but also effectively improves the website's SEO performance and optimizes the user experience.Let's explore together how to achieve this goal in Anqi CMS. ### Core Basics: Understanding the Classification System of AnQi CMS In AnQi CMS, the construction of multi-level product classification navigation is inseparable from its core "content model" and "document classification" functions. First

2025-11-09

How to get and display the custom Banner image group of the `categoryDetail` tag?

In website operation, configuring unique visual elements for different category pages, such as customized banner image groups, is crucial for enhancing user experience and strengthening brand recognition.AnQiCMS (AnQiCMS) leverages its flexible content management capabilities, allowing users to easily set up exclusive Banners for each category and provides intuitive template tags for conveniently displaying these contents on the frontend page.We all know that when users browse a website, the category page is a key entry point for them to explore content.

2025-11-09

How to effectively display the description (Description) and content (Content) on the front page?

In AnQi CMS, the description (Description) and content (Content) are key elements for website content organization and search engine optimization (SEO).Effectively display this information on the front page, not only providing visitors with clear navigation and in-depth information, but also helping search engines better understand the theme of the page, thereby improving the visibility of the website.Let's explore how to flexibly display the description and content of categories in the Anqi CMS front-end template together.

2025-11-09