How to display the list of all documents associated with the Tag on the Tag detail page?

Calendar 👁️ 56

In content operation, tags (Tag) are a key tool for connecting content, enhancing user experience, and optimizing search engine optimization (SEO).A well-designed Tag detail page, not only allows users to quickly find related content of interest, but also clearly conveys the organization structure and thematic relevance of the website content to search engines.AnQi CMS as an efficient and flexible content management system provides powerful and intuitive support in this regard, allowing content operators to easily achieve fine-grained content operation.

Today, let's delve into how to meticulously craft each Tag detail page in AnQiCMS, displaying all associated document lists, thereby fully unleashing the operational potential of Tags.

Understand the AnQiCMS tag mechanism and template layout

The Anqi CMS is well-designed in the aspect of Tag management, it is not just simple tagging for articles or products, but also gives Tags their own detail pages.These pages are inherently SEO-friendly, which can help search engines better understand the relevance of your content and improve keyword rankings.When you add a Tag to an article or product, you can visit the exclusive URL of that Tag (for example/tag/SEO优化.html),and you can see a customized page for that Tag.

In the AnQiCMS template system, each Tag's detail page corresponds to a preset template file. Usually, this template file is located in your current template directory.tagIn the folder, and namedlist.html(i.e.),/template/你的模板目录/tag/list.htmlIf you want to customize the display for a specific Tag, you can also create something liketag/{TagID}.htmlortag/{TagURL别名}.htmlThe template file. Understanding the structure of this template is the first step in building the Tag detail page.

Core: Build the Tag detail page template

We need to on the Tag detail page to display all related document liststag/list.htmlIn the use of the Tag template (or you can customize your own template) provided by AnQiCMS.This includes obtaining information about the Tag itself, calling the associated document list, implementing pagination, and improving SEO, among other tasks.

1. Obtain the detailed information of the Tag itself

On the Tag detail page, we first need to display the current Tag's name, description, and other information. AnQiCMS providestagDetailtags, which can be easily obtained.

You can use it like thistagDetailTag to display the title and description of the current Tag:

<main>
    <h1>{{ tagDetail with name="Title" }}</h1>
    <p>{{ tagDetail with name="Description" }}</p>
    {# ... 其他内容 ... #}
</main>

Here, name="Title"will directly output the title of the current Tag,name="Description"The description information of the Tag is output. This information can be directly used in the page.<h1>Title and summary, allowing users to understand the theme of the current page at a glance.

2. List display of associated documents

Now, we come to the most critical part - displaying the document list associated with the current Tag. AnQiCMS providestagDataListLabel. This label is very intelligent, in the Tag detail page, it will automatically identify the current Tag's ID, without manual specification, it can directly obtain all associated documents under the Tag.

To implement pagination of the document list, we usually willtypethe parameter to"page"andlimitparameters control the number of documents displayed per page.

{% tagDataList archives with type="page" limit="10" %}
    <section class="tag-documents">
        {% for item in archives %}
            <article class="document-item">
                <a href="{{ item.Link }}" class="document-link">
                    {% if item.Thumb %}
                        <img src="{{ item.Thumb }}" alt="{{ item.Title }}" class="document-thumbnail">
                    {% endif %}
                    <h2 class="document-title">{{ item.Title }}</h2>
                </a>
                <p class="document-description">{{ item.Description|truncatechars:150 }}</p>
                <div class="document-meta">
                    <span>发布于:{{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
                    <span>浏览量:{{ item.Views }}</span>
                    {% if item.CategoryId %}
                        {# 调用文档所属分类信息 #}
                        <span>分类:<a href="{% categoryDetail with name='Link' id=item.CategoryId %}">{% categoryDetail with name='Title' id=item.CategoryId %}</a></span>
                    {% endif %}
                </div>
            </article>
        {% empty %}
            <p class="no-documents-tip">当前Tag下暂无相关文档。</p>
        {% endfor %}
    </section>
{% endtagDataList %}

In the above code snippet:

  • archivesIt is the variable name we define, which will carry the document list data queried from the database.
  • type="page"It is the key to pagination, it tells the system that we need a paged list.
  • limit="10"It specified that 10 documents are displayed per page.
  • {% for item in archives %}Loop through each document,itemwhich is the current document object being looped to.
  • We displayed the title of the document (item.Title), link (item.Link), description (item.Description, usingtruncatecharsFiltering is performed (truncation), thumbnail (item.Thumb),release time(item.CreatedTimethrough.stampToDateFormatting) and view count (item.Views)
  • {% categoryDetail ... %}Tags are used to dynamically retrieve the title and link of the category to which each document belongs, further enriching the document information.
  • {% empty %}Block is a very practical feature, whenarchivesWhen the list is empty, it will display the prompt "There are no related documents under the current Tag", to avoid blank content on the page.

3. Implement pagination function

Now

Related articles

How to get the SEO title and description information of a specified Tag using the `tagDetail` tag?

As an experienced website operations expert, I know that in today's highly competitive digital environment, every detail can affect the visibility and user experience of a website.AnQiCMS (AnQiCMS) provides powerful tools for our refined operation with its high efficiency, flexibility, and SEO-friendly features.Today, let's delve deeply into a very practical template tag in AnQi CMS, `tagDetail`, and see how it helps us accurately obtain and optimize the SEO title and description information of the specified Tag (label) page.

2025-11-07

How to create an independent Tag detail page in AnQiCMS ( `tag/index.html` )?

## Create an independent Tag detail page in AnQiCMS (`tag/index.html`) As an experienced website operations expert, I fully understand the great potential of tags (Tag) in content organization and Search Engine Optimization (SEO).A well-designed tag page that not only helps users find relevant content quickly but also brings valuable long-tail traffic to the website.AnQiCMS as an enterprise-level content management system based on the Go language excels in providing efficient and customizable content management solutions

2025-11-07

How to implement a hot tag cloud effect using `tagList` in AnQiCMS?

In the surge of digital content operation, Tag Cloud, as a direct and efficient way of information aggregation, has always been favored by website operators and users.It can not only help users quickly find the key content of the website, but also effectively improve the website's SEO performance, guide the spider to crawl, and increase the page PV.As an experienced website operations expert, I deeply understand the strong and flexible tag management capabilities of AnQiCMS (AnQi CMS).

2025-11-07

Where does the `tagList` tag return the 'Tag Link' field point to?

As an experienced website operations expert, I fully understand that every detail in a content management system can affect the performance of the website, user experience, and even search engine rankings.Today”。 --- ### AnQiCMS `tagList` tag link field points to where

2025-11-07

How to accurately retrieve related documents based on `tagId` for the `tagDataList` tag?

As a senior website operations expert, I have a deep understanding of AnQiCMS's powerful content management capabilities.In daily operations, the refined organization and efficient distribution of content are crucial for improving user experience and SEO performance.Today, we will delve into a very practical template tag in AnQiCMS, `tagDataList`, and see how it helps us accurately retrieve related documents based on `tagId`, thus better constructing the content ecosystem.

2025-11-07

Does AnQiCMS's Tag document list (`tagDataList`) support filtering by content model?

As an experienced website operation expert, I am willing to deeply analyze the `tagDataList` tag filtering function in AnQiCMS.Today, being able to flexibly organize and present content is crucial for improving user experience and optimizing SEO.AnQiCMS on this aspect, with its powerful content model and tag management features, provides us with many conveniences.

2025-11-07

How to implement document sorting and pagination display on the Tag document list page?

AnQi CMS is an efficient and flexible content management system, and its Tag feature is an important way to organize and discover content.When a user visits a specific Tag page, they often expect to see all documents related to that Tag, and these documents should be presented in an orderly and easy-to-browse manner.This involves how to implement document sorting and pagination display on the Tag document list page.

2025-11-07

How to apply the `tagDetail` tag's 'Logo' field on the Tag detail page?

As an experienced website operations expert, I am well aware of how to fully utilize each field in a content management system to transform it into an effective tool that attracts users and enhances the value of the website.AnQiCMS (AnQiCMS) with its flexible and versatile characteristics, provides us with a lot of room to maneuver.Today, let's talk about the `tagDetail` tag, which has a seemingly ordinary but limitless potential field - 'Logo', and see how it shines on the Tag detail page.

2025-11-07