How to display the Tag list associated with the article in AnQiCMS?

Calendar 👁️ 62

In AnQiCMS, effectively managing and displaying the list of tags (Tag) for articles can not only help organize content but also significantly improve the internal link structure and search engine optimization (SEO) of the website.Tags act as a flexible classification method, linking articles across categories and themes, providing users with a richer browsing path.

Manage and create article tags in the background

First, understand how to add and manage tags for articles in the AnQiCMS backend is fundamental.When you publish or edit a document, you will see a dedicated 'Tag Tag' input box.Here, you can select an existing tag or directly enter a new tag name, then press Enter to convert it into a new tag.This means the process of creating tags is very convenient, you can add new ones whenever you need according to the content of the article.

The power of tags lies in their flexibility: they do not depend on fixed classification levels, and the same tag can be shared by articles of different content models (such as articles, products).In the "Content Management" module, under the "Document Tag" feature, you can centrally view, edit, and delete all tags that have been created.Each tag can still have an independent "custom URL" set, which is crucial for improving the SEO performance of the tag page, allowing search engines to better crawl and index.In addition, tags also support settings such as 'SEO title', 'tag keywords', 'tag description', etc., to help you manage the meta information of each tag page in detail.

Display associated tags on the article detail page

In AnQiCMS, to display the tag list associated with the current article at the bottom or sidebar of the article detail page, you need to use template tagstagList. This tag is used to retrieve the tag data of a specified document.

Generally, in the template of an article detail page (such asarchive/detail.htmlor a custom article template), you can call it in this way:

<div>
    <strong>相关标签:</strong>
    {% tagList tags with itemId=archive.Id limit="10" %}
    {% if tags %}
        {% for item in tags %}
            <a href="{{item.Link}}" class="tag-link">{{item.Title}}</a>{% if not forloop.Last %}, {% endif %}
        {% endfor %}
    {% else %}
        暂无相关标签
    {% endif %}
    {% endtagList %}
</div>

In this code:

  • {% tagList tags with itemId=archive.Id limit="10" %}:tagListIs the tag for getting the tag list.tagsIs the variable name we define for the tag list data.itemId=archive.IdIs critical, it tells the system to get the current article (by thearchive.IdAll tags associated with the identifier.limit="10"It limits the display of up to 10 tags, you can adjust the number according to your design requirements.
  • {% for item in tags %}: Loop through each tag obtained.
  • {{item.Link}}: Displays the URL link of the tag, clicking on it will jump to the article list page under the tag.
  • {{item.Title}}: Displays the name of the tag.
  • {% if not forloop.Last %}, {% endif %}This is a little trick to add a comma separator after each tag name, but not the last one, making the display more beautiful.

This way, when users visit the article detail page, they can see all the tags involved in this content, making it easier for them to explore related topics further.

Create an independent tag list page

In addition to displaying on the article detail page, you may also want to have a dedicated page listing all the tags on the website, or popular tags. This is usually in the template directory,tag/index.htmlImplement in the file.

To display all tags on the website, you can use this method.tagListTags:

<h1>所有标签</h1>
<div class="tag-cloud">
    {% tagList allTags with itemId="0" limit="50" %}
    {% if allTags %}
        {% for item in allTags %}
            <a href="{{item.Link}}" title="查看所有含“{{item.Title}}”标签的文章" class="tag-item">{{item.Title}} ({{item.ArchiveCount}})</a>
        {% endfor %}
    {% else %}
        目前还没有创建任何标签。
    {% endif %}
    {% endtagList %}
</div>

here,itemId="0"It means to get all tags, not the tags of a specific article.limit="50"It limits the maximum display of 50 tags. You can evenitem.Titleadd it besideitem.ArchiveCountto display how many articles are under the tag, increasing the reference for user selection.

Display the article list under a certain tag

When a user clicks on a tag link (for example{{item.Link}}) they usually expect to see a list of all articles containing that tag. AnQiCMS provides for thistagDataListLabels, this feature is usually implementedtag/list.htmlin the template.

In this template, the system automatically identifies the current label ID being accessed. You can display all articles under this label like this:

<h1>标签:{% tagDetail with name="Title" %} 下的文章</h1>
<div class="article-list">
    {% tagDataList archives with type="page" limit="10" %}
    {% if archives %}
        {% for article in archives %}
            <div class="article-item">
                <h2><a href="{{article.Link}}">{{article.Title}}</a></h2>
                <p>{{article.Description}}</p>
                <div class="article-meta">
                    <span>发布于:{{stampToDate(article.CreatedTime, "2006-01-02")}}</span>
                    <span>阅读量:{{article.Views}}</span>
                </div>
            </div>
        {% endfor %}
    {% else %}
        当前标签下暂无文章。
    {% endif %}
    {% endtagDataList %}

    {# 分页导航 #}
    {% pagination pages with show="5" %}
        <div class="pagination-nav">
            {% if pages.PrevPage %}<a href="{{pages.PrevPage.Link}}">上一页</a>{% endif %}
            {% for pageItem in pages.Pages %}
                <a href="{{pageItem.Link}}" class="{% if pageItem.IsCurrent %}current{% endif %}">{{pageItem.Name}}</a>
            {% endfor %}
            {% if pages.NextPage %}<a href="{{pages.NextPage.Link}}">下一页</a>{% endif %}
        </div>
    {% endpagination %}
</div>

Here:

  • {% tagDetail with name="Title" %}Used to get the title of the current tag page, ensuring that the user knows which tag's content they are browsing.
  • {% tagDataList archives with type="page" limit="10" %}:tagDataListUsed to get the list of articles belonging to the current tag.archivesIs the variable name for article data.type="page"Enables pagination,limit="10"Sets 10 articles per page.

Related articles

How to call and display the form fields submitted by users in the AnQiCMS template?

AnQi CMS provides a flexible mechanism to handle the interactive content of websites, among which the message form is an important bridge for communication with users.When we need to collect diverse information from users, we often create custom message fields.How to accurately call and display these custom form fields configured in the backend template on the website's frontend, which is the key to achieving personalized user experience.In AnQiCMS, the display of the message form fields mainly depends on the use of template tags.

2025-11-08

How does AnQiCMS display the comment list on article or product detail pages?

In website operation, user interaction is an important link to enhance the value of content and the level of website activity.The comment function serves as a bridge for users to directly communicate with content, not only enriching the page content, but also bringing unique UGC (User Generated Content) to the website, enhancing the community atmosphere, and also positively affecting search engine optimization (SEO).AnQiCMS (AnQiCMS) provides a powerful and flexible comment list display feature, allowing you to easily display user comments on articles or product detail pages and manage them effectively.

2025-11-08

How to dynamically display the breadcrumb navigation of the current page in AnQiCMS template?

Build a user-friendly, SEO-friendly website in AnQiCMS, breadcrumb navigation is an indispensable element.It can clearly show the user's current location, help the user quickly backtrack, and provide valuable website structure information for search engines.AnQiCMS's powerful template engine provides a simple and efficient way to dynamically generate these navigation paths.AnQiCMS's template system adopts syntax similar to the Django template engine, which makes it very easy for content developers to control the display of page content through tags and variables

2025-11-08

How to build and display a multi-level website navigation menu in AnQiCMS?

In website operation, a clear and intuitive navigation menu is the core of user experience, it can not only guide visitors to quickly find the information they need, but is also an important part of website structure and SEO optimization.AnQiCMS as an efficient enterprise-level content management system, provides flexible and powerful navigation menu construction and display functions, helping you easily manage the hierarchical structure of your website.**One, build navigation menu in AnQiCMS background** The first step in building a multi-level navigation menu is to centrally manage it in the AnQiCMS background

2025-11-08

How to retrieve and display the friend link list in AnQiCMS template?

In website operation, friendship links are an important factor in improving website authority, increasing external traffic, and optimizing user experience.AnQiCMS (AnQiCMS) is well aware of this, and therefore provides a convenient friend link management function in system design, and supports flexible calling and display in templates.This article will provide a detailed introduction on how to retrieve and display the friend link list in your AnQiCMS template.### Management of friendship links: Starting from the background Before starting the template call, make sure that your website's background has configured the friendship links

2025-11-08

How to display the document list under a specific Tag in AnQiCMS?

In AnQiCMS, tags (Tag) are a powerful and flexible way to organize content, allowing you to associate documents in multiple dimensions without relying on traditional hierarchical classification structures.When you want to display all documents under a specific topic or keyword, it is particularly important to show the document list under a specific tag.This not only helps visitors find the content they are interested in faster, but also effectively improves the internal link structure and SEO performance of the website.

2025-11-08

How to dynamically retrieve and display the contact information of the website in AnQiCMS?

In today's digital age, a website's contact information is more than just cold numbers or addresses; it is a bridge for users to build trust and communicate with the company.Efficiently and accurately display this information on the website, and be able to update it flexibly as needed, which is crucial for any website operator.AnQiCMS as an enterprise-level content management system provides a very intuitive and powerful solution in this aspect, allowing you to easily manage these key information without touching complex code.This article will introduce how to configure and dynamically obtain the contact information of the website in AnQiCMS

2025-11-08

How to use the `if` tag for conditional judgment to control content display in AnQiCMS templates?

How to use the `if` tag for conditional judgment to control content display in AnQiCMS templates?When building website templates, we often need to display or hide specific content blocks based on different conditions.For example, the image will be displayed only when the article has a thumbnail, or the welcome message will be displayed only after the user logs in.In the AnQiCMS template system, the `if` tag is a powerful tool for implementing conditional judgments.It uses a syntax similar to the Django template engine, concise and expressive, making the content display logic clear and easy to understand

2025-11-08