How to implement content aggregation and thematic display based on `tagList` and `tagDetail` tags?

Calendar 👁️ 59

In content management and website operation, how to efficiently organize and display content is the key to improving user experience and SEO performance. AnQiCMS (AnQiCMS) provides powerful tag features, throughtagListandtagDetailThese template tags can easily implement content aggregation based on tags and thematic display, bringing more flexible categorization and a richer navigation experience to the website.

The role of tags in content aggregation

Tags (Tag) are an important way to organize content in a content management system, complementing the traditional category (Category).If categorization is a structured hierarchical relationship that assigns content to a specific field, then tags are a more flexible, flattened way of associating that can cross different categories, aggregating content with common themes or keywords together.

For example, an article about 'website optimization' can belong to the 'marketing' category, but it can also be tagged with 'SEO', 'user experience', 'content strategy', and other tags.These tags not only help users find related content quickly, but also provide richer semantic information for search engines, improving the SEO effect of the website.In AnQi CMS, the backend content management provides an intuitive label creation and management interface, allowing us to attach multiple labels to content models such as articles and products, and customize the URL alias, SEO title, and description of the labels, laying a foundation for refined operation.

tagListTags: Discover and display a diverse collection of tags

tagListTags are mainly used to display tag lists at various positions on the website, such as "Hot Tags", "Related Tag Cloud", or alphabetical tag index.It can help visitors quickly find the main topics and hot discussion topics on the website.

To usetagListWe usually define a variable to receive the list of tags, then iterate through them to display them. For example, displaying the top 10 tags in the website sidebar or footer:

<div>
    <h3>热门标签</h3>
    <ul>
        {% tagList tags with limit="10" %}
        {% for item in tags %}
        <li><a href="{{item.Link}}">{{item.Title}}</a></li>
        {% endfor %}
        {% endtagList %}
    </ul>
</div>

In this example,tagsIt is a variable defined by us,limit="10"Limited to displaying only 10 tags.item.Linkanditem.TitleRespectively obtained the link and title of the tags.

tagListAlso supports other parameters such asitemIdYou can get the list of tags associated with the specified document whenitemId="0"In this case, it will retrieve all tags instead of automatically reading the tags of the current document.categoryIdParameters allow us to filter tags under specific categories. If you need to create a tag index page and support pagination, you can settype="page", but this usage is usually onlytag/index.htmlortag/list.htmlTake effect in specific templates and need to be combinedpaginationTags to build page navigation

tagDetailTag: Deeply understand the topic page of a single tag

When a user clicks on a tag, they will usually enter a special 'tag topic page' or 'theme page'.This page should display the detailed information of the label, as well as all the content associated with the label.tagDetailThe role of the tag is to obtain detailed data of a single tag, providing data support for building such a special topic page.

In the tag topic page (for example, in)tag/detail.htmltemplate),tagDetailThe tag will default to reading the current page's tag ID. We canname="字段名称"to obtain specific attributes of the tag, such as the title, description, and even custom cover images.

<h1>{{ tagDetail with name="Title" }}</h1>
<p>{{ tagDetail with name="Description" }}</p>

{# 假设后台为标签上传了Logo图片,可以在专题页顶部展示 #}
{% set tagLogo = tagDetail with name="Logo" %}
{% if tagLogo %}
    <img src="{{ tagLogo }}" alt="{{ tagDetail with name="Title" }}" />
{% endif %}

tagDetailInclude the fields returnedId/Title/Link/Description/FirstLetter/Content(If the label has detailed content),LogoThis information can be used to enrich the topic page content, giving users a more comprehensive understanding of the theme represented by this tag.

tagDataListTag: Presents the aggregated content under the tag.

It is not enough to simply display the details of the label, the core of the label topic page is to present all the content associated with the label. At this point,tagDataListThe label comes in handy. It is specifically used to retrieve the document list under a specified label.

Generally,tagDataListwill be withtagDetailUsed on the same label topic page, throughtagIdParameters to specify which label's content to query.

{# 假设我们已经在当前页面通过URL获取到了当前标签的ID #}
{% set currentTagId = tagDetail with name="Id" %} {# 获取当前标签的ID #}

{% if currentTagId %}
    <h2>与 "{{ tagDetail with name="Title" }}" 相关的内容</h2>
    <ul>
        {% tagDataList archives with tagId=currentTagId type="page" limit="10" %}
        {% for item in archives %}
        <li>
            <a href="{{item.Link}}">
                <h3>{{item.Title}}</h3>
                <p>{{item.Description}}</p>
                <span>发布日期:{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
            </a>
        </li>
        {% endfor %}
        {% endtagDataList %}
    </ul>

    {# 结合分页标签显示分页导航 #}
    <div>
        {% pagination pages with show="5" %}
            <a href="{{pages.FirstPage.Link}}">首页</a>
            {% 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 %}
            <a href="{{pages.LastPage.Link}}">末页</a>
        {% endpagination %}
    </div>
{% else %}
    <p>未找到相关标签信息或内容。</p>
{% endif %}

In this example, we first obtain the ID of the current tag and then pass it totagDataList.type="page"the parameter so that the content list can be displayed in pages and passed throughpaginationCreate a complete pagination navigation. This way, users can browse all the content related to the tag on the tag topic page and can easily navigate through the pages.

Optimize the use of tags: improve user experience and SEO

The Anqi CMS tag function does not stop at the content display level, its powerful backend configuration capabilities also provide strong support for SEO.We can set independent SEO titles, keywords, and descriptions for each tag, even customize static URLs, making each tag topic page an independent traffic entrance, optimizing search engine crawling and ranking.

Rational utilizationtagListandtagDetailTags, not only can they improve the internal link structure of a website and enhance the browsing depth of users within the site, but they can also turn the website into an authoritative resource in a specific thematic field through refined content aggregation, thereby effectively enhancing the overall value of the website.


Frequently Asked Questions (FAQ)

  1. What is the difference between Tag and Category in Anqi CMS?Tags and categories are both ways of organizing content, but they have different focuses.Categories are usually used to establish the hierarchical structure of content, assigning content to a fixed, broader field, such as "news", "tutorials", "products".And the tags are more flexible, they can cross categories, linking content of different categories but related in theme, such as "SEO", "Go language", "website skills".A content can belong to only one category, but can have multiple tags.

  2. How can I implement pagination on my tag topic page?To implement pagination on the tag topic page (usuallytag/list.htmlortag/index.htmltemplate), you need to usetagDataListSet a tag,typethe parameter to"page"And specifylimitparameters to control the number of articles displayed per page. After that, combinepaginationCreate pagination links. For example: `{% tagDataList archives with tagId=Current tag ID type=“page” limit

Related articles

How to manage and display independent single-page content for the `pageList` and `pageDetail` tags?

In website operation, in addition to dynamically updated articles or product lists, we often need to display some relatively fixed and independent content pages, such as "About Us", "Contact Information", "Privacy Policy" or "Service Introduction" and so on.These pages are usually called "single-page content". AnQiCMS provides us with powerful and flexible tools for managing and displaying these pages, especially the core tags `pageList` and `pageDetail`.### Single Page Content: The Foundation of a Website Single page content is an indispensable part of a website

2025-11-08

How are the `categoryList` and `categoryDetail` tags used to build and display the hierarchical structure of the website?

In Anqi CMS, the classification hierarchy of the website is the core of content organization, which not only affects the user's browsing experience, but is also an important link in search engine optimization.To effectively build and display these classification structures, we mainly rely on two powerful template tags: `categoryList` and `categoryDetail`.They work together, allowing you to flexibly present clear and organized content categories on the website front-end.### Build the category list: `categoryList` tag `categoryList`

2025-11-08

How to retrieve and display the detailed information of a single document, including its custom fields, using the `archiveDetail` tag?

In a content management system, effectively displaying the detailed information of a single document is one of the core requirements.Whether it is news articles, product introductions, or service descriptions, users always hope to have a direct and comprehensive understanding of the specific content of each item.AnQiCMS provides a powerful `archiveDetail` tag, allowing you to easily retrieve and display all information of a single document, including your custom exclusive fields.### Retrieve the core information of the document: `archiveDetail`

2025-11-08

How does the `archiveList` tag control the display quantity, sorting method, and pagination logic of the document list?

In AnQi CMS, the `archiveList` tag is undoubtedly a core tool for content display, providing great flexibility and control for the website's content list.Whether you want to display the latest articles on the homepage or implement complex filtering and pagination on the category page, `archiveList` can help us present content accurately through its rich parameter configuration.Next, let's delve into how to use this tag to control the display quantity, sorting method, and the implementation of exquisite pagination logic of the document list.### Control Document Display Quantity

2025-11-08

How to generate and control the pagination display effect of the `pagination` tag?

In website operation, when the amount of content is large, how to efficiently and beautifully display these contents while ensuring that users can browse conveniently is the key to improving user experience.If you dump all the content on the same page, not only will it load slowly, but it will also deter visitors.At this moment, content pagination becomes particularly important. It breaks massive information into several pieces, which not only reduces the burden of page loading but also allows users to explore the content they are interested in step by step at their own pace.AnQiCMS provides a powerful and flexible `pagination` tag

2025-11-08

How to implement conditional display and loop display of dynamic content in AnQiCMS template using `if` and `for` tags?

In the Anqi CMS template world, `if` and `for` tags are the foundation for building dynamic and flexible pages.They give the template the ability to display content based on different data conditions, as well as the ability to efficiently loop through data sets, making your website content生动地呈现给visitors vividly.AnQi CMS adopts a template engine syntax similar to Django, making it easy for you, who is familiar with web development, to get started quickly, obtaining data through double curly braces `{{variable}}`, and using `{% tags %}` syntax for conditional judgment and loop control.### Use `if`

2025-11-08

How to format a timestamp with the `stampToDate` tag to display the date and time in a user-friendly manner?

In the daily content operation of Anqi CMS, we often need to present the original timestamp data such as publish time and update time in a way that is more accustomed to and easier to read for users.The original timestamp, such as `1609470335` such a pure number sequence, has no meaning to ordinary users.To solve this problem, AnQi CMS provides a very practical template tag——`stampToDate`, which can help us convert these numeric timestamps into a clear and user-friendly date and time display.###

2025-11-08

How to retrieve and display the global configuration and SEO information of the website using `system`, `contact`, and `tdk` tags?

In the daily operation of AnQiCMS (AnQiCMS), accurately displaying global configuration information, contact information, and carefully optimized SEO elements on the website front end is the key to improving user experience and search engine visibility.Fortunately, AnQiCMS provides several intuitive and powerful template tags that allow users to easily access this important data.This article will delve into the three core tags `system`, `contact`, and `tdk`, helping you seamlessly integrate the background configuration into various pages of the website.Get the global configuration of the website

2025-11-08