How to display the `tagList` and `tagDataList` tags showing the website tags and related document list?

Calendar 👁️ 62

In website operation, a tag (Tag) is an extremely useful content organization tool.They can not only help users find the content they are interested in faster, improve the user experience of the website, but also optimize the search engine's crawling and understanding of the website content, which has a positive effect on SEO performance.tagListandtagDataListThese template tags allow us to easily display a list of tags on the website as well as documents related to specific tags.

Manage your website tags flexibly.

In Anqi CMS, tags are cross-content model and category, which means the same tag can be applied to different types (such as articles, products) and documents under different categories.This makes the content association closer, and also provides users with more dimensions of content navigation.You can find the 'Document Tag' feature in the 'Content Management' module on the backend to perform tag add, delete, modify, and query operations.Here you can set the tag name, index letter, custom URL, SEO title and description, etc., which lays the foundation for front-end display and SEO optimization.

Next, we will delve into how to utilizetagListandtagDataListthese core tags to build an efficient tag display and content association on your website.

UsetagListTag display website tag list

tagListTags are mainly used to display lists of tags at various locations on the website, such as the 'Hot Tags' area in the sidebar, the 'Tag Cloud' at the bottom of the website, or an independent tag index page.It can help users get an overview of the main content themes on the website.

When we want to display a series of tags in a template, we can use it like thistagList:

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

In this code block,tagsis the variable name we give to the tag listlimit="10"Then it specifies the first 10 tags we want to display. By loopingtagsVariable, we can obtain detailed information about each tag, such as the title of the tag{{item.Title}}and the link of the tag{{item.Link}}and then display it on the page.

tagListTags also provide some practical parameters to meet different display requirements:

  • itemId: This parameter is very useful, when you want to display related tags with the current article on the article detail page, you can specify it.itemIdIt will default to reading the ID of the current document. If you want to display tags for the entire site (for example, on the homepage or a global tag cloud), you can explicitly set ititemId="0".
  • limit: Control the number of displayed tags. For examplelimit="20"It can display 20 tags. It even supports"offset,limit"patterns, such aslimit="5,10"indicating starting from the 5th tag and getting 10 tags.
  • letter: If you want to filter tags by the first letter, for example, to only display tags that start with 'A', you can useletter="A".
  • categoryId: You can call the tag list under a specific category, for example, only displaying all tags under the 'news' category.
  • type="page"When you need to create an independent pagination page for a tag list (for example, a tag index page,tag/index.html), you can settype="page", then combinepaginationtags to achieve pagination display.

By combining these parameters, you can flexibly control the display range, number, and sorting of tags, providing users with clear navigation.

UsetagDataListTags display the document list under a specific tag.

When a user clicks on a tag, it usually jumps to a page that displays all the documents associated with the tag. At this time,tagDataListTags come into play. They can retrieve and display the associated document list based on the specified tags.

Assuming you have created a tag detail page (usually the template file istag/list.htmlortag/index.html),and hope to display all documents under the current tag on this page, you can use it like thistagDataList:

{% tagDataList archives with type="page" limit="10" %}
    {% for item in archives %}
    <article>
        <h2><a href="{{item.Link}}">{{item.Title}}</a></h2>
        <p>{{item.Description}}</p>
        <div>
            <span>发布于:{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
            <span>浏览量:{{item.Views}}</span>
        </div>
    </article>
    {% empty %}
    <p>该标签下暂时没有文档。</p>
    {% endfor %}

    {# 分页导航 #}
    {% pagination pages with show="5" %}
        {# 这里是分页链接的展示代码 #}
    {% endpagination %}
{% endtagDataList %}

In this code block,archivesis the variable name we use for the document list,type="page"andlimit="10"It means that we will display pagination with 10 records per page. In the tag detail page,tagDataListusually it is not necessary to specifytagId, it will automatically identify the tag ID of the current page.

tagDataListThe tag also supports rich parameters:

  • tagId: Specify the tag under which the document should be queried. It is usually used on non-tag detail pages, while on tag detail pages, it will default to fetching the tag ID of the current page.
  • moduleId: If your website has multiple content models (such as articles, products), you can filter to display only the documents under the article model bymoduleId="1"(assuming 1 is the article model ID).
  • order: Control the sorting method of documents, for exampleorder="views desc"Sorted in descending order by views,order="id desc"Sorted in descending order by the most recent release.
  • limit: Similar totagListcontrol the number of documents returned.
  • type="page": Enable pagination feature, withpaginationTags can build a complete pagination navigation.
  • siteId: If you use the multi-site feature, you can specify from which site to retrieve the data.

CombinetagDataListandpaginationTags, you can create a comprehensive and rich document list page for each tag, greatly enhancing user experience and content discoverability.

Integrate and apply to enhance the value of website content

Of Security CMStagListandtagDataListTags work together to help you build a dynamic and organized website content structure. First, you can usetagListDisplay popular tags on the sidebar or bottom of the website to guide users to the tag detail page; then, in the tag detail page, utilizetagDataListProvide all relevant documents under the tag for users.

This process of “Tag list -> Tag document list”, not only allows users to quickly filter content by topic, but also provides a clear website structure for search engines, helping to improve the inclusion and ranking of website content.By carefully designing tags and making good use of these two tags, your website will take a new step in content organization and SEO.


Frequently Asked Questions (FAQ)

Q1: I want to display related tags with the current article on each article detail page of the website, how should I operate?

A1:You can usetagListTags, and do not need to be explicitly specifieditemIdparameter. WhentagListThe tag is called on the document detail page, it intelligently identifies the current document ID and automatically loads the tags associated with the document. For example:

<h4>相关标签:</h4>
{% tagList tags %}
    {% for item in tags %}
        <a href="{{item.Link}}" class="tag-item">{{item.Title}}</a>
    {% endfor %}
{% endtagList %}

Q2: If my website has a very large number of tags, how can I avoid displaying a long list of tags on the page or implement pagination?

A2:For cases with a large number of tags, you cantagListlabel'slimitParameters to control the display quantity, for examplelimit="20"Only the first 20 tags will be displayed. If you need an independent tag index page and implement pagination, you can use it on the tag homepage (usuallytag/index.html)tagListand settype="page"then cooperate withpaginationtags to generate pagination navigation:

{# 标签列表分页显示示例 #}
{% tagList tags with type="page" limit="20" %}
    {% for item in tags %}
        <a href="{{item.Link}}" class="tag-cloud-item">{{item.Title}}</a>
    {% endfor %}
    {# 结合分页标签 #}
    {% pagination pages with show="5" %}
        {# 完整的分页链接代码,这里省略 #}
    {% endpagination %}
{% endtagList %}

Q3: Can I display documents under a specific tag in other non-tag pages of the website, such as a module on the homepage?

A3:Of course you can. You can usetagDataListLabel, and throughtagIdThe parameter explicitly specifies which label's documents to retrieve. First, you need to know the ID of the target label (which can be viewed on the "Document Label" management page in the background).Assuming the target tag ID is 5, and you want to display 3 articles under this tag on the homepage:

`twig

Latest recommendation: Document about 'AnQi CMS'

{% tagDataList archives with tagId=“5” limit=“3” order=“id desc” %}

{% for item in archives %}
<div class="featured-article">
    <h4><a href="{{item.Link}}">{{item.Title}}</a></h4>
    <p>{{item.Description|truncatechars:100}}</p>
</div>
{% endfor

Related articles

How do the `pageList` and `pageDetail` tags manage and display the single-page content of a website?

In website operation, single-page content (such as "About Us", "Contact Information", "Service Introduction", etc.) plays a crucial role.They are usually carriers that display the core information of a company, brand story, or specific service details.To efficiently manage and display these pages, AnQiCMS provides the `pageList` and `pageDetail` two core tags, making content organization and presentation both flexible and convenient.### Back-end management of single-page content In AnQiCMS back-end

2025-11-08

How to use `categoryList` and `categoryDetail` tags to build and display category navigation and details?

In website content management, category navigation and detail pages are the core paths for users to browse the website and obtain information, as well as an important basis for search engines to understand the website structure.A clear and intuitive classification system not only greatly enhances the user experience, but also effectively helps the website's SEO performance.For users of Anqi CMS, flexibly using the `categoryList` and `categoryDetail` template tags provided by the system can easily build powerful, beautiful, and practical classification navigation and detail display.--- ### One

2025-11-08

How is the `archiveDetail` tag used to retrieve and display detailed content information for a single document?

In AnQi CMS, the `archiveDetail` tag is a very core and practical tool for template creation, mainly used to retrieve and display detailed content information of a single document.Whether it is a blog post, product details, news report, or any other page content that needs to be independently displayed, `archiveDetail` can help you flexibly extract and present it on the website's front-end page.### `archiveDetail` Tag Core Function Overview The purpose of this tag is to provide rich data support for a single document

2025-11-08

How to use the `archiveList` tag in AnQiCMS templates to flexibly display document lists?

In AnQi CMS, when we need to dynamically display articles, products, or other document lists on the website, the `archiveList` tag is an indispensable core tool.It provides high flexibility and powerful features, whether you want to display the latest content, hot articles, products in specific categories, or even generate lists based on keyword search or custom filtering conditions, `archiveList` can easily handle it.### `archiveList` core functionality and basic usage `archiveList`

2025-11-08

How to use the `navList` tag to create and display multi-level navigation menus to optimize user browsing?

In website operation, a clear and intuitive navigation system is a key factor in improving user experience, guiding users to explore content, and even optimizing search engine rankings.A well-designed multi-level navigation menu can help visitors quickly find the information they need, reduce the bounce rate, and effectively enhance the in-depth access to website content.In AnqiCMS, the `navList` tag is the core tool to achieve this goal, allowing us to flexibly build and display hierarchical navigation menus to optimize the user's browsing path.### Understand the `navList` tag

2025-11-08

How to automatically generate and display the `breadcrumb` tag showing the user's current location in the breadcrumb navigation?

During website browsing, you may often see a line of text links at the top of the page or above the content area, like breadcrumbs, indicating your current position in the website and the path to get here.This is what we commonly call 'Breadcrumb Navigation'.It can not only help users quickly understand their hierarchical structure on the website, avoid getting lost, but also improve the usability of the website and play a positive role in search engine optimization (SEO).For AnQiCMS users, implementing such a feature is very simple and efficient

2025-11-08

How does the `pagination` tag add and control pagination display for document lists to enhance user experience?

When building a website, as the amount of content grows, the document list page becomes long, which not only affects the page loading speed but also makes it difficult for visitors to find the information they need efficiently.At this time, adding pagination to the document list becomes a key factor in improving user experience.AnQiCMS provides a powerful `pagination` tag, combined with the document list tag `archiveList`, it can easily achieve this goal, making your website content display more professional and more user-friendly.

2025-11-08

How to dynamically fetch and display the global settings and contact information of the website using the `system` and `contact` tags?

In AnQi CMS, the global settings and contact information are the basic information that constitutes the important facade of the website.This information must be displayed accurately to visitors, and more importantly, it should be able to be updated and managed flexibly and conveniently without frequent modifications to the template code.AnQi CMS provides these two powerful tags, `system` and `contact`, allowing website operators to easily achieve dynamic acquisition and display of this information.

2025-11-08