How to get the name, link, and description of a specified Tag?

Calendar 👁️ 64

As an experienced website operations expert, I know that effectively utilizing tags (Tags) in a content management system is crucial for the SEO, content organization, and user experience of the website.AnQiCMS (AnQiCMS) with its powerful template features and flexible tag system allows you to easily display and manage this valuable information on the website front-end.Today, let's delve deeply into how to accurately obtain the name, link, and description of a specified Tag in AnQiCMS, thereby providing stronger support for your content operations.

In AnQiCMS, tags are not just an accessory attribute of articles, but also exist as an independent content entity in themselves, having their own names, links, and descriptions.This design allows the tabs to become valuable traffic entry points and improve user experience through personalized display.AnQiCMS template language is similar to Django, with a simple and intuitive syntax. Even operators without a deep programming background can quickly get started.

Master the core tags of Tag data

To get the name, link, and description of the Tag, we mainly use the two core template tags provided by AnQiCMS:tagDetailandtagListThese tags are used to retrieve detailed information for a single specific Tag and to iterate over multiple Tag lists.

1. Retrieve detailed information for a specified Tag (tagDetail)

When you need to retrieve the complete information of a specific Tag (for example, you know its ID or URL alias),tagDetailThe tag is your preference. It can help you accurately extract the name, link, description, even including the index letter or custom content of the Tag.

Usage scenario:

  • On the Tag detail page, display the detailed introduction of the current Tag.
  • On the article detail page, display the exclusive description of the Tag based on the main Tag of the article.
  • Display information of a fixed Tag at a specific location, such as a specific recommendation tag in the "Hot Tags" area.

tagDetailthe basic usage of tags is{% tagDetail 变量名称 with name="字段名称" id="TagID" %}. Among them:

  • 变量名称: You can choose to assign the obtained data to a variable so that it can be referenced multiple times in the template. If you do not specify a variable name, the data will be output directly.
  • name="字段名称"This is the most critical part, you need to pass throughnamethe parameters to specify the specific fields you want to retrieve, such asTitle(Name),Link(Link),Description(Description) and others.
  • id="TagID"ortoken="URL别名"You can use Tag'sIDor itsURL别名Specify the specific Tag to retrieve information. If you are on the Tag detail page, it is usually not necessary to specify, as the system will automatically identify the Tag of the current page.
  • siteId="站点ID"In multi-site management, if you need to obtain Tag information under other sites, you can use this parameter. Generally, it is not necessary to fill in.

Available field name: Besides the name, link, and description,tagDetailother useful fields are provided, such as:

  • Id: The unique identifier ID of the Tag.
  • Title: The name of the Tag.
  • Link: The link address corresponding to the Tag.
  • Description: The description content of the Tag.
  • FirstLetter: The first letter of the Tag name (used for alphabetical sorting, etc.).
  • Content: Custom content of the Tag (if set in the background).
  • Logo: Thumbnail or Logo of the Tag (if set in the background).

Actual application example:

Assuming you have a Tag's ID is5Or its URL alias isanqicms-tips.

Get the name of the specified Tag:

{# 直接输出 Tag ID 为 5 的名称 #}
<div>指定 Tag 名称:{% tagDetail with name="Title" id="5" %}</div>

{# 将 Tag ID 为 5 的名称赋值给变量 'myTagName' 并输出 #}
{% tagDetail myTagName with name="Title" id="5" %}
<p>我的专属标签名称是:{{ myTagName }}</p>

{# 如果是当前 Tag 详情页,通常可省略 ID,例如 URL 别名为 anqicms-tips 的页面 #}
<p>当前页面标签名称:{% tagDetail with name="Title" %}</p>

Get the link of the specified Tag:

{# 直接输出 URL 别名为 'anqicms-tips' 的 Tag 链接 #}
<p>相关主题链接:<a href="{% tagDetail with name="Link" token="anqicms-tips" %}">点击查看更多安企CMS技巧</a></p>

{# 将 Tag 链接赋值给变量 'myTagLink' 并输出 #}
{% tagDetail myTagLink with name="Link" token="anqicms-tips" %}
<p>访问 {{ myTagLink }} 获取更多信息。</p>

Get the description of the specified Tag: The description of the Tag may contain rich text or HTML, therefore it is recommended to use|safeA filter to prevent content from being escaped, thus rendering HTML structure correctly.

{# 直接输出 Tag ID 为 5 的描述 #}
<div class="tag-description">
    {% tagDetail with name="Description" id="5" %}|safe %}
</div>

{# 将 Tag 描述赋值给变量 'myTagDescription' 并输出 #}
{% tagDetail myTagDescription with name="Description" id="5" %}
<div class="tag-intro">{{ myTagDescription|safe }}</div>

By these methods, you can flexibly obtain and display detailed information about a specified Tag at any location on the website, whether it is used to beautify the page, improve the user experience, or strengthen the relevance of the content.

Second, traverse and obtain the basic information of multiple Tags (tagList)

In addition to getting the details of a single Tag, you may also need to display multiple Tags, such as showing related Tags at the bottom of an article, creating a Tag Cloud, or displaying popular Tags in the sidebar. At this point,tagListthe tag comes into play.

Usage scenario:

  • List all the Tags associated with the current article on the article detail page.
  • Display a list of popular Tags on the homepage or sidebar.
  • Build a Tag index page, listing all Tags by alphabet or category.

tagListthe basic usage of tags is{% tagList 变量名称 with limit="数量" %}And it needs to match withforLoop to iterate through each Tag.

  • 变量名称: Usually named astagsOr another meaningful name, used toforiterate in the loop.
  • limit="数量": Limit the number of returned Tags, for examplelimit="10"Display only 10 Tags. You can also useoffsetpattern, such aslimit="2,10"Start retrieving 10 records from the second one.
  • itemId="文档ID"If you want to get the Tag associated with a specific document (article or product), you can use this parameter.If not specified, and the current page is the document detail page, it will try to get the Tag of the current document.To get all Tags, you can set it toitemId="0".
  • letter="首字母": Filter by the first letter of the Tag name, for exampleletter="A"Only display Tags starting with A.
  • categoryId="分类ID": Filter by the category ID of the Tag.
  • siteId="站点ID": SametagDetailFor multi-site management.

tagListThe tag will return a Tag object.

Related articles

How to display the details of a single Tag in AnQiCMS template?

As an experienced website operations expert, I am happy to give you a detailed explanation of how to flexibly and efficiently display the detailed information of a single Tag in AnQiCMS.AnQiCMS with its concise and efficient architecture provides powerful template customization capabilities for content operators.To deeply understand the presentation of individual Tag information, we first need to start with its template mechanism and core tags.How to display the details of a single Tag in AnQiCMS template?

2025-11-07

How to get the Tag list starting with a specific letter in AnQiCMS?

As an experienced website operation expert, I am happy to discuss the subtle aspects of AnQiCMS (AnQiCMS) in content operation with you.AnQiCMS with its efficient and customizable features, provides a powerful toolkit for content creators and operators.Today, let's delve into a specific and practical scenario: how to elegantly obtain a list of Tags starting with a specific letter in AnQiCMS, thereby achieving more refined content organization and display.

2025-11-07

How to display the AnQiCMS tag list by page number (limit)?

As an experienced website operations expert, I know that how to efficiently and flexibly display content in a content management system is the key to operational success.AnQiCMS with its concise and efficient architecture and powerful template tag system, provides us with great convenience.Today, let's delve into a common but crucial feature: how to implement pagination of the tag list by call quantity (limit) in AnQiCMS.

2025-11-07

How to get the list of Tag tags for a specified document?

As an experienced website operations expert, I am well aware of the importance of tags (Tag) in content management and website optimization.They can not only help users quickly locate the content they are interested in, but also provide clearer website structure information for search engines, thereby improving SEO effectiveness.In such a powerful content management system as AnQiCMS, it is a core skill for every operator and developer to master the flexibility of obtaining and displaying the Tag tag list of a specified document.

2025-11-07

How to retrieve the associated document list according to TagID in AnQiCMS?

## Unlock Content Association: How to Efficiently Retrieve Related Document Lists in AnQiCMS Tags are an important tool for connecting content, improving user experience, and optimizing search engine visibility in content management systems.AnQiCMS, as an enterprise-level content management system developed based on the Go language, is well-versed in this field and provides flexible and powerful tag features.For website operators, how to accurately obtain and display the document list associated with a specific tag ID is a key link in the realization of refined content operation.

2025-11-07

How to display and sort the Tag document list with pagination?

As an experienced website operations expert, I know that the core value of a content management system (CMS) lies in its flexibility and fine control over content display.AnQiCMS (AnQiCMS) performs particularly well in this aspect, thanks to its efficient architecture based on the Go language and its rich set of features.For daily content operations, how to efficiently organize and display the document list under the tag (Tag), while providing friendly pagination and sorting features, is a key factor in improving user experience and website SEO performance.

2025-11-07

Does the AnQiCMS Tag tag support cross-content model usage?

## Boundary Breaking: How does AnQiCMS's Tag tag implement cross-content model management?As an experienced website operations expert, I know that the flexibility of the Content Management System (CMS) is crucial for efficient operation.AnQiCMS, with its efficient architecture based on the Go language and rich features, stands out in small and medium-sized enterprises and content operation teams.Amongst the seemingly basic yet extremely crucial function of "Tag Label", its design philosophy and application often reflect the depth and practicality of a CMS system.

2025-11-07

How to add a new document tag in the AnQiCMS backend management?

As an experienced website operations expert, I am well aware of the powerful and convenient content management capabilities of AnQiCMS.Label, this seemingly insignificant feature is actually a powerful tool for connecting content, enhancing user experience, and optimizing search engine performance.Today, let's delve into how to add new tags flexibly and efficiently to your documents in the AnQiCMS backend management.

2025-11-07