How to display the description and link of a specific Tag label in AnQiCMS?

Calendar 👁️ 70

In Anqi CMS, a tag (Tag) is a powerful content organization tool that not only helps you classify content more accurately but also optimizes the website's SEO performance and improves the user's browsing experience.Sometimes, you may want to display not only the name of the label at a certain position on the front end of the website, but also its more detailed description information, and even jump directly to the link related to the content of the label.

This is not a difficult matter, Anqi CMS provides flexible template tags, allowing you to easily meet these needs.We will start from the background settings and gradually delve into the actual application of the front-end templates, ensuring that you can fully master them.

1. Add description and link for Tag label in the background

Firstly, we need to ensure that each Tag label has a complete description and correct link structure. These configurations are completed in the Anqi CMS backend.

  1. Enter the Tag label management interface:Log in to the Anqi CMS backend and navigate to the 'Document Tag' option under 'Content Management' via the left menu.
  2. Create or edit Tag labels:In the document tag list, you can choose to edit an existing tag, or click "Add new document tag" to create a new tag.
  3. Perfect the Tag tag information:On the label editing page, there are several key fields directly related to our goal:
    • Tag name:This is the display name of the label, which is also the most basic identifier.
    • Custom URL:This field allows you to set a personalized, SEO-friendly link alias for tags.The Anqi CMS usually automatically generates pinyin URLs based on tag names, but you can manually modify them to ensure uniqueness and semanticization.This custom URL will directly affect the jump link of the front-end tag.
    • Tag description:This is the place where you add descriptive text for the Tag tag.This content can be a brief overview of the tag topic, or some guiding information, which will be displayed on the front end.
    • SEO title and label keywords:Although it is not directly displayed, these fields are crucial for improving the search engine visibility of the tab page, and it is recommended that you also improve them.

After completing these settings, save your changes. Now, your Tag tag is equipped with callable description and link information.

Second, display the description and link of the Tag label on the website front-end

The AnQi CMS uses a syntax similar to the Django template engine, calling back-end data through specific template tags. We will demonstrate how to operate in several common scenarios.

1. Display the list and description of all Tag tags

If you want to display all or part of the Tag tags on the website sidebar, footer, or dedicated tag aggregation page, and include their descriptions and links, you can usetagList.

tagListThe label is mainly used to obtain the list of document labels. When you want to obtain all tags (instead of the tags of a specific document), you need toitemIdthe parameter to0.

<div class="tag-cloud">
    <h3>热门标签</h3>
    {% tagList tags with itemId="0" limit="20" %} {# 获取所有标签,限制显示20个 #}
    {% for item in tags %}
        <div class="tag-item">
            <a href="{{ item.Link }}" title="{{ item.Description }}">{{ item.Title }}</a>
            {% if item.Description %}
                <p class="tag-description">{{ item.Description }}</p>
            {% endif %}
        </div>
    {% empty %}
        <p>目前还没有任何标签。</p>
    {% endfor %}
    {% endtagList %}
</div>

Code analysis:

  • {% tagList tags with itemId="0" limit="20" %}This line of code will retrieve all the Tag tags on the website and store them in a variable namedtags.limit="20"It limits the display to only the 20 most recently added tags.
  • {% for item in tags %}:TraversetagsEach tag data in the variable.
  • {{ item.Link }}Display the link address of the tag.
  • {{ item.Title }}Display the name of the tag.
  • {{ item.Description }}Display the introduction (description) set in the background for the tag.
  • {% if item.Description %}This is a conditional judgment, only when the label has a description is it displayedp.

2. Display specific Tag details on the Tag label detail page

When the user clicks on a Tag label to enter its detail page (usually corresponding totag/list.htmlortag/index.htmlWhen using a template), you may wish to display detailed information such as the name, description, and even images of the Tag at the top of the page. In this case,tagDetailTags come into play. On the Tag detail page,tagDetailIt will default to retrieving information about the current Tag.

<div class="tag-detail-header">
    {% tagDetail tagInfo with name="Title" %} {# 获取当前Tag的标题,并赋值给tagInfo变量 #}
    {% tagDetail tagDescription with name="Description" %} {# 获取当前Tag的描述,并赋值给tagDescription变量 #}
    {% tagDetail tagLogo with name="Logo" %} {# 获取当前Tag的Logo,并赋值给tagLogo变量 #}

    {% if tagLogo %}
        <img src="{{ tagLogo }}" alt="{{ tagInfo }}" class="tag-logo">
    {% endif %}
    <h1>{{ tagInfo }}</h1>
    {% if tagDescription %}
        <p class="intro">{{ tagDescription }}</p>
    {% endif %}

    {# 如果需要显示当前标签下的文档列表,可以结合 tagDataList 标签 #}
    <h3>“{{ tagInfo }}”相关文章:</h3>
    <ul class="archive-list">
        {% tagDataList archives with tagId=tag.Id type="page" limit="10" %} {# 获取当前标签下的文章,每页10条 #}
        {% for doc in archives %}
            <li>
                <a href="{{ doc.Link }}">
                    <img src="{{ doc.Thumb }}" alt="{{ doc.Title }}" />
                    <h4>{{ doc.Title }}</h4>
                </a>
                <p>{{ doc.Description|truncatechars:100 }}</p> {# 截取文章描述前100字 #}
            </li>
        {% empty %}
            <li>暂无相关文章。</li>
        {% endfor %}
        {% endtagDataList %}
    </ul>

    {# 分页导航(如果使用了 type="page") #}
    <div class="pagination">
        {% pagination pages with show="5" %}
            {# ... 分页链接代码,可参考tag-/anqiapi-tag/149.html文档示例 ... #}
        {% endpagination %}
    </div>
</div>

Code analysis:

  • {% tagDetail tagInfo with name="Title" %}In the Tag details page, you can directly go throughname="Title"To get the title of the current Tag and assign it totagInfothe variable. Similarly, getDescriptionandLogo.
  • {{ tagInfo }}/{{ tagDescription }}/{{ tagLogo }}Output these variable values.
  • {% tagDataList archives with tagId=tag.Id type="page" limit="10" %}This line of code will retrieve all documents associated with the current Tag and perform pagination. Here is thetag.IdIt will automatically retrieve the Tag ID of the current page.
  • {{ doc.Link }}/{{ doc.Title }}/{{ doc.Thumb }}/{{ doc.Description|truncatechars:100 }}: Traverse the document list and output the document's link, title, thumbnail, and extracted description.

3. Display the associated Tag tags on the document detail page.

On the article or product detail page, you would usually like to display all the Tag tags associated with the current document in the bottom or sidebar.

`twig

Related articles

How to list all Tag tags in the AnQiCMS template?

In Anqi CMS, using the template function to display all Tag tags on the website is an important operation that helps improve content discoverability and website SEO.AnQiCMS as an efficient content management system provides an intuitive and flexible tag (Tag) management mechanism, allowing users to easily list this content in website templates. ### Learn about AnQiCMS's Tag Function In AnQiCMS, tags (Tag) can be seen as topics or keywords that connect different content.They do not follow a strict hierarchical structure like categories

2025-11-08

How to use the filtering feature of AnQiCMS to display a document list under specific conditions?

How to manage a large amount of content in AnQiCMS and allow users to quickly find the information they need is one of the key factors in content operation.Fortunately, AnQiCMS provides powerful filtering functions, allowing you to flexibly display document lists according to specific conditions, thereby greatly enhancing the website's user experience and content search efficiency. ### Clearly define your filtering requirements: Starting from the backend content model To make use of AnQiCMS's filtering feature, you first need to clarify the conditions through which you want users to search for content.

2025-11-08

How to dynamically display custom parameter fields of articles or products in AnQiCMS?

When building and operating a website, we often need to display more information than just the title and content, such as product models, colors, inventory, or the author, source, and publishing platform of the article.AnQiCMS knows the importance of personalized content display, and therefore provides a highly flexible custom parameter field function, making website content management and frontend display both powerful and convenient.Next, let's delve deeper together on how to make full use of this feature in AnQiCMS, making your website content dynamic.### First Step

2025-11-08

How to display related article recommendations on the AnQiCMS article detail page?

In website operation, the related article recommendation function on the article detail page can not only effectively improve the user's browsing depth within the site, reduce the bounce rate, but also guide users to discover more valuable content, indirectly improving the overall SEO performance of the website.AnQiCMS as a content management system that focuses on efficiency and scalability, provides flexible template tags, making it intuitive and convenient to implement this function. Let's discuss together how to elegantly implement related article recommendations on the article detail page of AnQiCMS.

2025-11-08

How to retrieve and display the list of documents under a specific Tag label in AnQiCMS?

In Anqi CMS, managing website content, the Tag tag is undoubtedly a very flexible and practical tool that helps us classify different categories and even different model content according to themes, greatly enriching the organization of content and the browsing experience of users.So when we want to display a list of all documents under a specific Tag on a dedicated page, Anqi CMS provides a very intuitive and powerful template tag to help us achieve this goal.### Understanding the role of Tag tags in Anqi CMS Before delving into the code

2025-11-08

How to display the comment list of a document in AnQiCMS and implement pagination?

In Anqi CMS, adding a comment list to the document page and implementing pagination is a key step to enhancing user interaction experience.This can not only let visitors participate in discussions and share opinions, but also brings more vitality to the website content.AnQi CMS provides intuitive and powerful template tags, allowing us to easily implement these features. ### Integrate the comment feature into your document detail page Comment lists and comment forms are typically integrated into the detail page of the document.

2025-11-08

How to generate and display the website's message form in AnQiCMS templates?

In website operation, an efficient and convenient feedback form is an important bridge for user interaction with the website.It not only collects user feedback, but also serves as the entry point for potential customers to obtain information.AnQiCMS as an enterprise-level content management system provides powerful and flexible functions in this aspect, allowing us to easily generate and manage comment forms in templates.

2025-11-08

How to get and display the list of friendship links configured in the AnQiCMS background?

In website operation, friendship links play an indispensable role. They not only bring valuable external traffic to the website but also help improve search engine optimization (SEO) effects, enhance the authority and credibility of the website.For users using AnQiCMS, managing and displaying friend links is a simple and efficient process.This article will introduce in detail how to configure friend links in the AnQiCMS background, as well as how to elegantly present them in your website front-end template.In AnQiCMS admin manage friend links First

2025-11-08