How to display the related Tag tag list of articles or products on the AnQiCMS detail page?

Calendar 👁️ 68

How can we make users find the content they are interested in more efficiently in website operation, while also improving the visibility of the content, which is a problem we often think about.The product or article detail page, in addition to the core content, providing a list of related Tag tags is undoubtedly a good method to achieve this goal.AnQiCMS as a flexible and efficient content management system provides an intuitive and powerful Tag tag feature, allowing you to easily display these related information on the detail page.

Understand the AnQiCMS Tag label feature

On AnQiCMS backend, adding Tag tags to articles or products is very intuitive.When you edit or publish content, in the "Tag Tag" section, you can either select existing tags or enter a new tag and press Enter to add it.These tags act as index keywords for the content, not only helping you better organize and classify the content, but also providing users with another way to explore the website's content.For example, an article about "AnQiCMS deployment", you can add tags such as "AnQiCMS", "deployment", "Go language CMS", etc.After reading the article, if the user is interested in 'Go language CMS', they can click on the label directly, and the system will display all related articles or products.

Call related Tag labels list on the detail page

To be in the article or product detail page (usually{模型table}/detail.htmlThe template file shows these associated tags, AnQiCMS provides specialtagListLabel. This label is very smart, when used on the detail page, it will default to getting the ID of the current article or product asitemId, so in most cases, you do not need to manually specify this parameter.

Its basic usage is as follows:

{% tagList tags %}
    {% for item in tags %}
        <a href="{{ item.Link }}">{{ item.Title }}</a>
    {% endfor %}
{% endtagList %}

Here, tagsThis is a variable name defined for the tag list, you can change it according to your preference.tagListTags will retrieve all the Tags related to the current content andforLoop to output. Inside the loop,item.Linkthe link address of Tag will be output,item.TitleThen the Tag name is output. When users click on these links, they can jump to the Tag aggregated list page, where they can see all articles or products marked with that Tag, greatly enhancing the relevance of content and users' browsing depth.

If you want to limit the number of displayed Tags, you can uselimitParameters. For example, to display up to 5 tags, you can write it like this:

{% tagList tags with limit="5" %}
    {% for item in tags %}
        <a href="{{ item.Link }}">{{ item.Title }}</a>
    {% endfor %}
{% endtagList %}

This way, even if an article is associated with ten or more tags, only the first five will be displayed on the page, keeping the page concise.

Combined with practice: a complete code example.

Assuming we are editing a template for an article detail page, we hope to display related Tag tags below the article title, publication date, and other information. The following is a code snippet combined with article basic information and Tag list:

<article class="article-detail">
    {# 显示文章标题 #}
    <h1>{{ archive.Title }}</h1>

    <div class="article-meta">
        {# 显示发布日期和浏览量 #}
        <span>发布日期:{{ stampToDate(archive.CreatedTime, "2006-01-02") }}</span>
        <span>浏览量:{{ archive.Views }}</span>

        {# 调用当前文章的所有相关Tag标签 #}
        <div class="article-tags">
            <strong>相关Tags:</strong>
            {% tagList articleTags with limit="10" %} {# 限制最多显示10个Tag #}
                {% for item in articleTags %}
                    <a href="{{ item.Link }}" class="tag-item">{{ item.Title }}</a>
                {% endfor %}
            {% endtagList %}
        </div>
    </div>

    {# 显示文章主要内容,注意使用|safe过滤器确保HTML内容正确解析 #}
    <div class="article-content">
        {{ archive.Content|safe }}
    </div>

    {# 这里可以继续添加上一篇/下一篇、相关文章推荐等内容 #}
</article>

In this example,archive.Title/archive.CreatedTime/archive.Viewsandarchive.ContentThese are the current article/product fields that are directly available in the article detail page template. We havetagListplaced the tags indivand used<strong>tags to explicitly indicate that these are “related Tags”, and then iterate over themarticleTagsVariable, generate a clickable link for each Tag.

Cautionary notes and **practice

  1. The number of Tags is moderate:Avoid stacking too many tags on the detail page. Too many tags not only affect the appearance of the page but may also distract the user's attention and even be misjudged by search engines as over-optimization.It is usually recommended to have 5-10 tags per content.
  2. Tag names should be concise and relevant:The name of the tag should accurately reflect the core theme of the content and be as concise and clear as possible. This is convenient for users to understand and also beneficial for SEO.
  3. Regularly check and maintain the Tag:As the content of the website grows, duplicate, outdated, or irrelevant Tags may appear. Regularly cleaning and merging Tags can maintain the clarity and vitality of the website's content structure.
  4. Style beautification:Ensure that the style of the Tag list is consistent with the overall design style of the website, making them look like part of the content rather than an abrupt presence.For example, add background color, rounded corners, or different font sizes to Tag links to enhance the visual effect.

By following these steps, AnQiCMS allows you to easily display the related Tag tag list on the content detail page.This not only adds effective navigation dimensions to your website content, but also greatly optimizes the user experience and the understanding of website content by search engines, thereby improving the overall operation effect of the website.


Frequently Asked Questions (FAQ)

1. How do Tag tags affect a website's SEO?The impact of tags on SEO is mainly reflected in the following aspects: first, it provides more keyword signals to search engines, helping search engines better understand the theme of the page.Secondly, each Tag page will aggregate related content, form internal links, enhance the website's link structure, and help improve the page authority.In the end, appropriately set tags can enhance user experience, increase the time users spend on the website, and indirectly send positive signals to search engines.

2. Can I limit the number of Tag tags displayed on the detail page?Of course. IntagListYou can use in the tag,limitParameters to specify the maximum number of displayed Tag count. For example,{% tagList tags with limit="5" %}Only the first 5 Tag tags associated with the current article or product will be displayed.

How do I display a list of articles under a specific Tag on non-article/product detail pages?If you want to display a specific Tag

Related articles

What content models does AnQiCMS support, and how can they be flexibly displayed on the front end?

In AnQi CMS, content is not just simple articles or products, it is a dynamic ecosystem that allows users to freely define and display various types of information according to their actual business needs.This high degree of flexibility is due to its powerful content model support and the limitless possibilities brought by the front-end template engine. ### Flexible and diverse content model: the skeleton of information One of the core advantages of Anqi CMS is its highly flexible content model.It is not preset with a few fixed content types to limit your choices, but provides a powerful mechanism that allows users to build like building blocks

2025-11-09

How to customize the display of the publication time and page views of articles using AnQiCMS template tags?

In the display of website content, the publication time and the number of views of the article are important elements in conveying information to readers and enhancing the value of the content.A clear publication time allows readers to understand the timeliness or timeliness of the content, while the number of views can reflect the popularity of the content.AnQiCMS with its flexible template mechanism allows us to easily customize the display of this key information to adapt to the design styles and user needs of different websites.

2025-11-09

How to get and display the record number and copyright information of the website in the AnQiCMS template?

In the operation of the website, the filing number (ICP) and copyright information are essential elements for building user trust and compliance with laws and regulations.It is crucial to clearly display this information for websites built using AnQiCMS, whether it is a corporate website or a personal blog.Luckily, AnQiCMS provides a very intuitive and flexible way to manage and display this content. Next, we will together learn how to obtain and display the website filing number and copyright information in the AnQiCMS template.

2025-11-09

How to implement multilingual content switching and correct display on the front end of AnQiCMS website?

When building a website for global users, providing multilingual content is a crucial step.AnQiCMS as a comprehensive content management system provides flexible and powerful support to achieve this goal.This article will discuss in detail how to implement multi-language content switching and correct display on the AnQiCMS website.## Global Website Creation: AnQiCMS Overview of Multilingual Capabilities AnQiCMS's multilingual support is designed to help website operators easily meet the needs of global content promotion.

2025-11-09

How to correctly parse and display HTML content in the rich text editor in the AnQiCMS template?

Managing website content in AnQiCMS, the rich text editor is undoubtedly our powerful assistant in creating rich and beautiful web pages.It allows us to easily add styles, images, links, even tables, making the content free from the boredom of plain text.However, ensuring that these meticulously edited rich text contents are presented correctly on the website's frontend template is a key skill that every AnQiCMS user needs to master.

2025-11-09

How to use AnQiCMS's pseudo-static function to optimize URL structure for better search engine display effect?

In website operation, a clear and meaningful URL address, like a business card of the website content, not only helps visitors quickly understand the theme of the page, but is also a key factor for search engines to identify, crawl, and rank the website content.A well-designed URL structure can significantly improve a website's performance in search engines and bring more natural traffic.AnQiCMS as an efficient content management system, understands the importance of URL structure for SEO, and therefore provides powerful and flexible pseudo-static functions to help us easily optimize the website's URL.### Static URL Rewriting

2025-11-09

How to implement lazy loading of images in document content in AnQiCMS to improve page loading speed?

In website operation, page loading speed is always one of the key factors affecting user experience and search engine optimization (SEO).Especially for websites with rich content, images are often the main factor that slows down page speed.Therefore, how to efficiently manage image resources has become an indispensable factor in improving website performance.Today, let's talk about how AnQiCMS cleverly implements lazy loading of images in document content, thus significantly improving page access speed.In AnQiCMS's design philosophy, website performance optimization is one of its core advantages.

2025-11-09

How to get and display the extended fields of a custom content model in the AnQiCMS template?

Flexibly obtain and display extended fields of custom content models in the AnQiCMS template, which is the key to achieving personalized content display on the website.AnQiCMS powerful content model customization capabilities, allowing us to add various unique attributes to articles, products, and other content according to actual business needs, and how to present these customized data beautifully in the frontend template is exactly the topic we are going to delve into today.### The Flexibility of AnQiCMS Content Model AnQiCMS is an enterprise-level content management system developed based on the Go language

2025-11-09