How to display all used Tag tags on the website or only display Tag tags related to the current article in AnQiCMS?

Calendar 👁️ 59

When building website content, tags play an important role. They can not only help you better organize information and improve the discoverability of content, but also optimize the user experience, making it easier for visitors to find content of interest.For a content management system, flexibly displaying and managing these tags is one of its core values.AnQiCMS provides powerful functions in this aspect, allowing you to easily control the display of tags on the website according to your actual needs.

Add and manage Tag tags

On the AnQiCMS backend, adding tags to articles or products is a straightforward process.When you edit or publish a document, you can find the "Tag" field in the "Other Parameters" collapse box.You can select an existing label or directly enter a new label name, then press Enter to convert it into a new label.You can add multiple tags to each article, and these tags are not limited to specific categories or content models. This means that the same tag can be associated with different types of content (for example, an article and a product can both have a "New Release" tag), which greatly increases the flexibility of content association.

You can also access the "Document Tags" feature under "Content Management" to centrally view and manage all tags, including modifying tag names, adding descriptions, or setting custom URLs.This centralized management approach ensures the tidiness and consistency of the tag library.

Display all Tag labels on the website

Sometimes, you may wish to display all the tags used in a certain area of the website, such as the sidebar or a dedicated tag cloud page, to enhance the website's navigation and content aggregation. AnQiCMS provides a very practicaltagListTemplate tags can easily meet this requirement.

When you usetagListlabel and specifyitemId="0"At that time, it will retrieve all Tag tags on the website. CombinedlimitParameters, you can control the number of tags displayed, for example, only display the most commonly used 50 tags. By using a simple loop, you can display these tags and their links on the page.

For example, in your template file (such astag/index.htmlOr in the public sidebar template), you can call it like this:

<div class="tag-cloud">
    <h3>热门标签</h3>
    {% tagList allTags with itemId="0" limit="50" %}
        {% for item in allTags %}
            <a href="{{item.Link}}" title="{{item.Title}}">{{item.Title}}</a>
        {% empty %}
            <span>暂无标签</span>
        {% endfor %}
    {% endtagList %}
</div>

This code will retrieve all the tags used on your website and display them as links, allowing visitors to clearly see the hot topics covered by the website.

Display tags related to the current article

And in the specific article or product detail page, we usually prefer to see tags that are only related to the current content. AnQiCMS also passes through.tagListThe tag provides a concise and efficient implementation method.

In the template of the article detail page (for example)archive/detail.html)tagListThe tag will intelligently identify the ID of the current article. You do not need to pass it manually.itemIdParameter, it will default to retrieving and displaying all tags associated with the current article. If you need to limit the number, you can also continue to use it.limitParameter.

In the article detail page, you can lay out the related tags in this way:

<div class="article-tags">
    <span>标签:</span>
    {% tagList relatedTags limit="10" %} {# 在文章详情页默认会自动关联当前文章ID #}
        {% for item in relatedTags %}
            <a href="{{item.Link}}" class="tag-link">{{item.Title}}</a>
        {% empty %}
            <span>本文暂无标签</span>
        {% endfor %}
    {% endtagList %}
</div>

In this way, when users read an article about 'Go Language Development', they can directly see related tags such as 'Go Language', 'Backend Development', 'Microservices', etc., which makes it convenient for them to explore related content further.

Label detail page content organization

When a user clicks on a label, they will be directed to a dedicated label detail page, usually corresponding to the template file istag/list.html. On this page, AnQiCMS providestagDetailandtagDataListtwo tags to help you build content.

First, you can usetagDetailTo get the detailed information of the current tag, such as the title and description:

<h1>标签:{% tagDetail with name="Title" %}</h1>
<p>{% tagDetail with name="Description" %}</p>

Next, to list all related articles under the tag, you need to usetagDataListLabel. This label will automatically filter out all documents marked with the current page's label ID. At the same time, it supportstype="page"parameters, allowing you to combinepaginationLabel, add pagination functionality to the article list under the label, so that it can be displayed well even if there is a large amount of content under the label.

A tag detail page article list part will generally be like this:

<div class="tag-articles">
    {% tagDataList archives with type="page" limit="10" %}
        {% for item in archives %}
            <article class="article-item">
                <h3><a href="{{item.Link}}">{{item.Title}}</a></h3>
                <p>{{item.Description|truncatechars:150}}</p>
                <div class="article-meta">
                    <span>发布日期:{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                    <span>浏览量:{{item.Views}}</span>
                </div>
            </article>
        {% empty %}
            <p>该标签下暂无相关文章。</p>
        {% endfor %}
    {% endtagDataList %}

    <div class="pagination-nav">
        {% pagination pages with show="5" %}
            {# 这里是分页导航的具体实现代码,您可以根据pagination标签文档进行配置 #}
            {% if pages.PrevPage %}<a href="{{pages.PrevPage.Link}}">上一页</a>{% endif %}
            {% for pageItem in pages.Pages %}<a class="{% if pageItem.IsCurrent %}active{% endif %}" href="{{pageItem.Link}}">{{pageItem.Name}}</a>{% endfor %}
            {% if pages.NextPage %}<a href="{{pages.NextPage.Link}}">下一页</a>{% endif %}
        {% endpagination %}
    </div>
</div>

By using a combination of these tags, AnQiCMS makes the tag feature on the website both flexible and powerful, whether it is a comprehensive tag display or a refined content association, it can be well supported.

Some practical suggestions

To fully utilize the value of the tags, here are some suggestions:

  • Maintain relevanceEach tag should be highly relevant to the content of the article, avoiding overly broad or imprecise words.
  • Control quantityEach article should not have too many tags, usually 3-5 core tags are enough to keep it concise and help improve the focus of the tags.
  • Unified specificationIn backend management, try to use a unified label format to avoid fragmentation caused by synonyms or inconsistent capitalization.For example, "SEO optimization" and "seo optimization" should be unified into a single tag.
  • Leverage SEO advantages: The tag page itself is a content aggregation page, appropriate tag descriptions and titles help search engines understand the theme and improve inclusion and ranking.

AnQiCMS provides high flexibility and practicality in tag management and display, helping you optimize the website structure, enhance user experience, and ultimately support your content marketing and SEO strategies.


Frequently Asked Questions (FAQ)

Q1: Can I display all tags on the website in different sizes based on their usage frequency (i.e., tag cloud effect)?

A1:

Related articles

How to create and display single-page content such as “About Us” and “Contact Us”?

In website operation, single-page content like "About Us", "Contact Us", and the like are windows to showcase the corporate image, core values, or provide key information to visitors.They usually carry stable, independent and infrequent updated content, which is crucial for building trust and providing service access.AnQiCMS provides very convenient and powerful functions for managing and displaying these single-page applications, allowing you to easily create and customize them.### Part 1: Create Your Single Page Content Creating a single page in AnQiCMS is an intuitive and efficient process

2025-11-08

How to display the top-level category list of a specific content model on the homepage or sidebar?

In AnQi CMS, managing website content, we sometimes need to clearly display the top-level category list of a specific content model at key positions such as the homepage or sidebar.This not only effectively guides visitors to browse the website content and improve user experience, but is also an important aspect of website content architecture optimization and search engine friendliness.Using AnQiCMS's flexible template system and powerful tag features, it is direct and efficient to meet this requirement. ### Understanding the Core: Content Model and Classification The core of content management in Anqi CMS lies in the "content model".You can create different content models based on business requirements

2025-11-08

How can I build and display a multi-level nested category navigation menu?

Building and displaying multi-level nested category navigation menus in Anqi CMS is an important aspect of website content organization and user experience optimization.A well-designed, hierarchical navigation not only helps visitors quickly find the information they need, but also provides clear website structure signals to search engines, thereby improving SEO effectiveness. AnQi CMS is an enterprise-level content management system developed in Go language, with flexible content models and powerful template tags, making it very intuitive and efficient to implement multi-level classification navigation.Next, we will explore how to step by step build such navigation

2025-11-08

How to display the 'Previous' and 'Next' article links and titles on the article detail page?

It is crucial to enhance user experience and content discoverability in website operation.When a reader is immersed in an article, providing navigation links to the "previous article" and "next article" can not only guide them to continue browsing the website's content but also effectively reduce the bounce rate and optimize the on-site SEO structure.For those of us using the AnQiCMS website to manage, implementing this feature is both simple and efficient.AnQiCMS provides a straightforward and powerful template tag system, making it easy to integrate 'Previous Article' and 'Next Article' links on article detail pages

2025-11-08

How to display a list of all related articles under a specific Tag tag?

In Anqi CMS, tags (Tag) are an important tool for organizing content, enhancing user experience, and optimizing search engine performance.It can link articles from different categories but with related themes, making it easier for visitors to find content they are interested in.When you need to display a list of all associated articles under a specific Tag label, AnQi CMS provides a concise and powerful template tag to help you achieve this goal.### Understanding the Core: `tagDataList` tag To display the article list under a specific Tag, we mainly use the built-in functions of Anqi CMS.

2025-11-08

How can I optimize the URL structure of the AnQiCMS website to improve search engine friendliness?

During the operation of a website, a good URL structure, like a clear map, can not only help users intuitively understand the content of the page, but also guide search engines to more efficiently crawl and understand your website.AnQiCMS was designed with SEO needs in mind from the beginning, built-in powerful URL management functions, allowing us to easily create a search engine-friendly website structure.Understanding why search engine friendly URLs are important Before delving into the specific features of AnQiCMS, let's talk briefly about it

2025-11-08

Can I customize the URL paths for articles, categories, and single pages, and how do I do it?

In website operation, a clear and meaningful URL path not only enhances user experience but is also one of the key factors in search engine optimization (SEO).AnqiCMS as an efficient content management system fully considers this need and provides the function of flexible customization of articles, categories, and single-page URL paths.How does AnqiCMS support custom URL?AnqiCMS has built-in powerful pseudo-static functions, which allows your website pages to be dynamically generated even if their content is dynamic

2025-11-08

How to dynamically set the Title, Keywords, and Description (TDK) information for each page?

In website operation, each page's Title (title), Keywords (keywords), and Description (description) information, which we commonly call TDK, plays a vital role.They are not only the key for search engines to understand page content, but also important factors to attract users to click.In AnQiCMS, dynamically setting this information for each page is much more efficient and flexible than you might imagine.How to make TDK settings efficient and convenient in AnQiCMS

2025-11-08