How to display the Tag of a specific document on a non-Tag page through the `tagList` and `itemId` parameters?

Calendar 👁️ 62

As an experienced website operations expert, I know that how to flexibly display information in a content management system is crucial for improving user experience and website SEO.AnQiCMS (AnQiCMS) offers great freedom to content operators with its powerful template tag system.Today, let's delve into a very practical scenario: how to accurately display tags associated with a specific document on non-tag aggregation pages (such as article detail pages or list pages).

Perceive the value of tags: It's not just classification, but also a hub of association

In AnQiCMS, tags are not just simple categorization of content; they are also important tools for connecting different content, building internal links, and guiding users to discover relevant information.When a user browses a document, tags that appear at the bottom or sidebar and are highly relevant to its content can effectively stimulate the user's desire for exploration, enhance the website's PV (page views) and user stay time, thereby conveying positive user behavior signals to search engines.

The AnQiCMS tag feature is powerful and easy to manage.In the background, you can add one or more tags to each document and perform unified management and SEO optimization for these tags.As a rule, you will find the Tag-specific page provided by AnQiCMS (such astag/index.htmlortag/list.html) See the tag list or the document list under a specific tag. But the true art of operation lies in how to extend the value of these tags to a broader non-tag aggregated page.

Core mechanism:tagListwith the tag anditemIdThe clever combination of parameters

The template tag system of AnQiCMS is very comprehensive, among whichtagListTags are used specifically to retrieve and display a list of tags. Its basic usage is to get tags for the entire site or a specified category.However, when we need it to “recognize” and display the tags of a specific document, we need to introduce a key parameter:itemId.

ThisitemIdThe power of parameters lies in the fact that it allows you to explicitly specify which document's label to retrieve. In short,itemIdLike an accurate pointer, tellingtagListPlease show me all the tags of the document represented by this ID.

To use successfullyitemIdThe core is to obtain the unique identifier ID of the target document.In the AnQiCMS template system, obtaining the document ID is usually very intuitive.Next, we will demonstrate how to flexibly apply this mechanism through specific scenarios.

Scenario one: Display the current document tags on the document detail page.

Assuming you are building a blog post detail page, and you want to list all the tags associated with the article you are currently reading below the article title or at the end of the content. At this time, the ID of the current document can be obtained througharchiveDetailtags easily.

First, in your document detail template file (for examplearchive/detail.htmlIn a custom document template), you need to obtain the current document ID. This can be achieved by the following AnQiCMS template code:

{# 首先,在文档详情页,获取当前文档的ID #}
{% archiveDetail currentArchiveId with name="Id" %}

{# 然后,使用这个ID作为tagList的itemId参数,展示相关标签 #}
<div class="document-tags">
    <span class="tags-label">相关标签:</span>
    {% tagList tags with itemId=currentArchiveId limit="10" %}
        {% for tagItem in tags %}
            <a href="{{ tagItem.Link }}" title="{{ tagItem.Title }}" class="tag-link">{{ tagItem.Title }}</a>
        {% empty %}
            <span class="no-tags">暂无相关标签</span>
        {% endfor %}
    {% endtagList %}
</div>

In this code, we first usearchiveDetailLabel, assign the ID of the current document tocurrentArchiveIdthis variable. Then, we willcurrentArchiveIdpass totagListofitemIdParameter.limit="10"control the maximum display of 10 labels,{% empty %}Blocks elegantly handles the case where the document has no tags, ensuring that the page does not appear blank or error.Finally, each tag will be presented with its title and link, and the user can click to jump to the aggregation page of the tag.

Scenario two: Display exclusive tags for each document in the document list loop

On the category list page or home page, you may need to list the corresponding tags for each displayed document item.For example, in an article list area, several related tags are displayed below the introduction of each article.In this case, the document ID is also accessible.archiveListIn the loop, each document item itself contains its ID, namelyitem.Id.

Please see the following AnQiCMS template code example, which shows how toarchiveListdynamically load and display tags for each document in a loop:

”`twig {# Assume this is a loop of document lists, such as on a category page or home page #} {% archiveList archives with type=“page” limit=“5” %}

{% for docItem in archives %}
<div class="article-card">
    <h3><a href="{{ docItem.Link }}">{{ docItem.Title }}</a></h3>
    <p class="description">{{ docItem.Description }}</p>
    <div class="article-tags">
        <span class="tags-label">标签:</span>
        {# 为当前循环中的文档项(docItem)展示标签 #}
        {% tagList tagsForDoc with itemId=docItem.Id limit="5" %}
            {% for tag in tagsForDoc %}
                <a href="{{ tag.Link }}" class="tag-badge">{{ tag.Title }}</a>
            {% empty %}
                <span class="no-tags">无标签</span>
            {% endfor %}
        {% endtagList %}
    </div>
</div>
{% end

Related articles

Does AnQiCMS's `tagDataList` support excluding documents with a specific `moduleId`?

As an experienced website operation expert, I deeply understand the powerful and flexible content management of AnQiCMS.In daily content operations, we often need to finely control the content displayed. Tags, as an important dimension of content organization, are crucial for the flexibility of their calling methods.Today, let's delve deeply into a frequently asked question: Does AnQiCMS's `tagDataList` tag support excluding documents with specific `moduleId`?

2025-11-07

How to call the list of all tags associated with the current document on the document detail page?

As an experienced website operations expert, I know the essence of content operations lies in how to organize information efficiently and present it to readers in the most intuitive and practical way.In AnQiCMS (AnQiCMS) such a powerful, SEO-friendly content management system, taking full advantage of its template tag system can greatly enhance the user experience and search engine performance of the website.Today, let's delve into a very practical scenario in content operation: how to call the list of all associated tags of the current document on the document detail page.

2025-11-07

Can AnQiCMS's `tagList` tag implement the 'weight' sorting or popularity display for Tag?

As an experienced website operations expert, I fully understand your need to sort the 'weight' or display popularity of the Tag feature in AnQiCMS (AnQiCMS).This not only concerns the SEO performance of the website, but is also the key to improving user experience and guiding content discovery.AnQi CMS, with its efficient and customizable features, provides us with a powerful content management foundation, but when it comes to the weight sorting of tags, we need to delve into its existing functions and potential expansion solutions.

2025-11-07

How does AnQiCMS handle URL conflicts for custom tags to ensure uniqueness?

As an experienced website operations expert, I know that every URL is crucial for the healthy operation of the website and search engine optimization (SEO).A clean, unique, and meaningful URL not only enhances user experience but is also the foundation for search engines to understand and index content.In AnQiCMS (AnQiCMS) such a content management system that focuses on SEO and efficient management, the uniqueness of the URL is naturally one of its core design considerations.Today, let's delve into a specific issue that may be encountered in operation: when you set a custom URL for Tag, if a conflict occurs

2025-11-07

Can the Tag label be combined with the 'Content Collection' function of AnQiCMS?

## Smart Collection: The Path of Collaborative Operation between Anqi CMS Content Collection and Tag Tags In this era of information explosion, the speed and quality of website content updates directly determine its visibility in search engines and its value in users' hearts.For the vast majority of small and medium-sized enterprises, self-media operators, and teams that need to manage multiple sites, efficiently obtaining and organizing content is undoubtedly a huge challenge.AnQiCMS (AnQiCMS) is an enterprise-level content management system developed based on the Go language, with its high performance, flexible customization, and SEO-friendly features

2025-11-07

How to troubleshoot template or URL configuration problems when the Tag page in AnQiCMS opens abnormally?

As an experienced website operations expert, I deeply understand the unique advantages that AnQiCMS demonstrates in providing efficient content management for small and medium-sized enterprises and content operation teams.It relies on the high performance, flexible content model brought by the Go language, as well as the deep optimization for SEO, and has become a powerful tool in the hands of many operators.However, even the most powerful system is bound to encounter some minor hiccups in use, such as the Tag page not displaying normally, which often confuses operation personnel.The Tag page, as an important part of AnQiCMS content organization and SEO strategy

2025-11-07

Why doesn't the front end display immediately after adding a new Tag in AnQiCMS?

As an expert who has been deeply involved in website operations for many years, I know that every detail in a content management system can affect the final presentation of the website.I completely understand the feeling of confusion and anxiety when you carefully add a new Tag label in the AnQiCMS backend, only to find that it is not displayed on the front end for a long time.AnQiCMS with its high efficiency, flexibility, and SEO-friendly features has become the preferred choice for many content operators. Understanding some of the underlying mechanisms behind it can help us navigate it more smoothly.

2025-11-07

How to ensure that the AnQiCMS Tag custom URL remains unique throughout the entire site?

As an experienced website operations expert, I know that every URL carries the value of the website content and the expectations of search engines.In a highly efficient and flexible content management system like AnQiCMS, fine-grained operation is particularly important, especially for Tag (tag) elements that carry the intent of content aggregation and SEO, the uniqueness management of its custom URL is an issue that we must understand and handle properly.Why is the uniqueness of Tag custom URL crucial?In AnQiCMS, Tag is used as a powerful content organization method

2025-11-07