If you want to get the details of a Tag label (such as name, link, description), which template tag should you use?

Calendar 👁️ 63

As an experienced website operation expert, I am well aware that flexibly using template tags in a high-efficiency content management system like AnQiCMS is the key to improving the efficiency of website content display and management.Especially for content organization forms like Tag tags, which are important, it is crucial to accurately obtain and display their detailed information, which is vital for SEO optimization and user experience.

Today, let's delve into a question that many people often encounter: 'If you want to get the detailed information (such as name, link, description) of a certain Tag label, which template tag should you use in Anqi CMS?'

Unveil the details of the Anqi CMS tag:tagDetailThe tag is your favorite

In the AnQi CMS template system, when you need to focus on a specific Tag label and extract its unique attributes, the system provides a template tag specifically designed for this purpose -tagDetail. It acts as a data scout, able to delve into the tag library, searching and returning all the detailed information you need.

tagDetailThe core function of tags is to obtainIndividual Tag tagThe complete data object or its specific fields. This means you can easily display a Tag's name, its corresponding link, and its description at any location on the website (such as the tag details page, the related tags area on an article details page, or the sidebar recommendation area).

How to usetagDetailTag information acquisition?

tagDetailThe use of tags is very intuitive, and it usually works with some parameters to accurately specify which information of which Tag you want to get.

  1. Specify Tag label method:

    • Automatically obtained on the current page:When you are on the detail page of a Tag label,tagDetailTags do not require any additional parameters to automatically identify and retrieve the Tag information of the current page. This is the most common usage and the most convenient way.
    • Specify through ID:If you know the unique ID of the Tag label (visible in the background management), you can specify it throughidparameters. For example,id="1"it will retrieve the Tag label with ID 1.
    • Specify through URL alias (Token):Tag labels usually have a readable URL alias (configured in the background, for exampleseo-optimization), and you can also usetokenthe parameter to specify. For example,token="seo-optimization"Get the Tag label with the alias “seo-optimization”.
  2. The specific field to be retrieved: tagDetailTag throughnameParameters allow you to precisely select the Tag information to display. The following are some common fields and their meanings:

    • Id: The unique identifier (ID) of the Tag tag.
    • Title: Tag label display name, this is the most intuitive information the user sees.
    • Link: The URL address corresponding to the Tag label, clicking on it will usually jump to the article list page under the Tag.
    • Description: A brief description of the Tag label, which is very helpful for SEO and users to understand the meaning of the label.
    • FirstLetter: The initial letter of the Tag label name, often used in alphabetical sorting of tag clouds.
    • LogoIf the label is configured with a Logo image, the URL can be obtained through this field.
    • ContentThe detailed content or description of the label (if filled in on the back-end).

An example of practical application: retrieve and display the name, link, and description of a Tag

Assuming you are building an article detail page, you want to list all the tags belonging to the article at the bottom of the page, and clicking on these tags can jump to their detail pages.Or do you want to display detailed information about a popular Tag in a sidebar.

The following is a simple code snippet that demonstrates how to retrieve the name, link, and description of a Tag:

{# 假设您正在Tag详情页,或者通过其他方式获得了当前Tag的上下文 #}

{# 示例1:获取当前Tag的标题并直接输出 #}
<div>当前Tag标题:{% tagDetail with name="Title" %}</div>

{# 示例2:获取指定ID的Tag链接 #}
<div>ID为10的Tag链接:<a href="{% tagDetail with name="Link" id="10" %}">点击查看</a></div>

{# 示例3:将Tag描述赋值给变量,然后输出 #}
{% tagDetail tagDescription with name="Description" %}
<p>标签描述:{{tagDescription}}</p>

{# 示例4:综合展示一个Tag的名称、链接和描述(通常在循环中或特定Tag展示区使用) #}
{% tagDetail featuredTag with id="5" %} {# 获取ID为5的特色Tag #}
{% if featuredTag %} {# 确保Tag存在才显示 #}
  <div class="featured-tag">
    <h3><a href="{{ featuredTag.Link }}">{{ featuredTag.Title }}</a></h3>
    <p>{{ featuredTag.Description }}</p>
    {% if featuredTag.Logo %}
      <img src="{{ featuredTag.Logo }}" alt="{{ featuredTag.Title }}" />
    {% endif %}
  </div>
{% else %}
  <p>特色标签未找到。</p>
{% endif %}

In the above example, we demonstrated three ways of obtaining: directly outputting a field, assigning a field to a variable and then using it, and obtaining the entire Tag object and accessing its properties through dot notation. Among them,featuredTag.Link/featuredTag.TitleandfeaturedTag.DescriptionIt is through the obtained Tag object that you can access its specific information.

Broaden your horizons:tagListwithtagDataList

AlthoughtagDetailFocus on the details of a single Tag, but in actual operation, you may also encounter the following needs:

  • Get the Tag list of all Tags or documents:When you want to display a list of all tags on a website, or the related tags of a particular article/product, you should usetagListLabel. It can return an array of Tag objects for you to loop through and display Tag names and links.

    {# 获取与当前文档相关的Top 10 Tag列表 #}
    {% tagList tags with itemId=archive.Id limit="10" %}
        {% for item in tags %}
        <a href="{{item.Link}}">{{item.Title}}</a>
        {% endfor %}
    {% endtagList %}
    
  • Get all documents under a certain Tag:If you want to display a list of all related articles, products, and other documents under the Tag on the detail page or topic page, thentagDataListThe label is your best choice. It will return an array of document (archive) objects.

    {# 在Tag详情页,获取当前Tag下的Top 10 文档列表 #}
    {% tagDataList archives with type="page" limit="10" %}
        {% for item in archives %}
        <a href="{{item.Link}}">{{item.Title}}</a>
        {% endfor %}
    {% endtagDataList %}
    

Understand the respective responsibilities of these tags, which will help you build the Tag feature of the website more efficiently and accurately.

**Tips for Practice**

  • Refer to the documentation:Although this article provides a detailed explanation, the official documentation of Anqi CMS is always your most reliable reference. When in doubt, please refer to it first.design-tag.md/tag-/anqiapi-tag/148.html/tag-archiveTag.mdandtag-/anqiapi-tag/149.htmland related documents.
  • Maintain consistency:When displaying Tag information on the website, try to maintain consistency in style and logic, which helps users better understand and navigate.
  • SEO friendly:The tag name, description, and link are important SEO elements. Ensure they are clear, accurate, and contain relevant keywords.

By cleverly usingtagDetailTags and their 'sibling' tags, you can make the Tag function of Anqi CMS website work to its maximum effect, whether it is to improve the discoverability of content, optimize search engine rankings, or improve the user's browsing experience, it will be twice as effective with half the effort.


Frequently Asked Questions (FAQ)

  1. Ask: I want to display a 'Hot Tags' list in the footer of the website, should I usetagDetailOrtagList?**Ans

Related articles

How to use the `{% tagList %}` tag to filter and display Tags in alphabetical order?

As an experienced website operations expert, I know that the organization and presentation of website content is crucial for user experience and Search Engine Optimization (SEO).AnQiCMS (AnQiCMS) provides powerful tools for content managers with its flexible template engine and rich tag system.Today, let's delve deeply into a common yet somewhat challenging requirement: how to elegantly sort and display the Tag of the website using the `{% tagList %}` tag.

2025-11-06

How to limit the number of `{% tagList %}` tags displayed on the page?

## Precisely Control: How to Limit the Number of Tags on the Page in Anqi CMS using `{% tagList %}` Tag Tags play a key role in modern website operations, connecting content, enhancing user experience, and optimizing search engine indexing.They can not only help users find relevant content quickly, but also provide strong support for the internal link structure and SEO strategy of the website.However, as with any excellent tool, it is crucial to use and manage tags reasonably.If we allow the page to load too many tags, it may backfire, leading to redundant pages and slow loading

2025-11-06

How to display all Tag tags associated with a document in AnQi CMS template?

AnQi CMS is an efficient and flexible content management system that provides rich features for content operators, among which 'tags' play a key role as an important means of content classification and association, contributing to the enhancement of website content structure, optimization of user experience, and SEO.As an experienced website operations expert, I know how to make full use of these tools to maximize the value of content.Today, let's talk about how to accurately display all the Tag tags associated with a document in the AnQiCMS template.

2025-11-06

How to configure a pseudo-static URL on the Tag tag page to optimize search engines?

Unlock the potential of search engine: AnqiCMS Tag page pseudo-static URL optimization configuration details In the ever-changing Internet world, the visibility of a website is the foundation of its success.For operators, how to make their content easier to be discovered by search engines and achieve good rankings has always been a core issue.AnQiCMS (AnQiCMS) as a system designed for content operations, knows this.

2025-11-06

The `{% tagDetail %}` tag can get which field data of Tag?

As an experienced website operations expert, I deeply understand the strong potential of Anqi CMS in content management and SEO optimization.Today, we will delve into a very practical template tag in AnQiCMS——`{% tagDetail %}`, which can help us manage and display website tag data more finely, thereby improving user experience and search engine friendliness.

2025-11-06

How to display the list of all associated documents under the Tag tag detail page?

As an experienced website operations expert, I am well aware of the core role of tags (Tag) in content management and website optimization.A well-designed tagging system not only enhances user experience and helps visitors quickly find the content they are interested in, but is also an indispensable part of search engine optimization (SEO).AnQiCMS provides very flexible and powerful support for the Tag tag function, making it easy for us to achieve this goal.

2025-11-06

What parameters does the `{% tagDataList %}` tag support to refine

Hello!As an experienced website operations expert, I am more than happy to provide a detailed explanation of the various parameters supported by the `{% tagDataList %}` tag in AnQiCMS, as well as how to skillfully utilize them to build more accurate and attractive content displays.In AnQiCMS, content tags (Tag) are an important way to organize and associate content, helping users quickly find topics of interest.

2025-11-06

How to display the Banner image list through the `bannerList` tag on the Anqi CMS homepage?

As an experienced website operations expert, I am well aware of the importance of the homepage banner for website visual appeal, user guidance, and brand promotion.In AnQiCMS such an efficient and flexible content management system, making good use of its built-in tags can help us easily achieve various content display needs.Today, let's delve into how to skillfully use the `bannerList` tag on the homepage of AnQiCMS to display your exquisite Banner image list.--- ### AnQiCMS and Banner

2025-11-06