How to display a list of tags and their details for all or specific articles on a website?

Calendar 👁️ 57

Hello!As an experienced AnQi CMS website operator, I fully understand your needs for the Tag function in content organization and optimization.Tags are an indispensable part of website content management, as they not only help users find relevant content faster, but also effectively improve the website's SEO performance.Below, I will explain in detail how to display the tag list and detailed information of all or specified articles on the AnQiCMS website.


Display the tag list and details of website articles in AnQiCMS

In Anqi CMS, the Tag feature provides a flexible and powerful way for content organization.By carefully setting and managing tags, you can associate articles of different categories, different models, but related to the same theme, which greatly facilitates users in exploring content and provides search engine crawlers with a clearer content structure.AnQiCMS provides dedicated template tags to help you display these tags and their associated content on the website front end.

Display the list of all website tags

If you need to display all or part of the popular tags on a page of the website, such as a "tag cloud" page or sidebar, you can use the tags provided by AnQiCMS.tagListLabel. This label can help you flexibly control the display quantity, sorting method, and even filter according to the first letter or category of the label.

You can define a tag list in the following way:

{% tagList tags with limit="50" order="id desc" %}
  <div class="tag-cloud">
    {% for item in tags %}
      <a href="{{item.Link}}" title="查看所有关于 {{item.Title}} 的文章">{{item.Title}}</a>
    {% empty %}
      <p>暂无可用标签。</p>
    {% endfor %}
  </div>
{% endtagList %}

In the above code,tagsIs the variable name you define for the tag list.limit="50"The parameter limits the maximum display of 50 tags,order="id desc"It specified to sort by tag ID in descending order. Inside the loop,item.LinkThe link to the tag detail page will be generated,item.TitleIt will display the tag name. If the website has not set any tags,{% empty %}The content within the block will be displayed.

If you want to display all tags on a dedicated tag index page (for example)tag/index.html) and support pagination, you can implement tags in the following way:tagListadd in thetype="page"the parameter and cooperatepaginationTag implementation:

{% tagList tags with type="page" limit="20" order="id desc" %}
  <ul class="tag-list-paginated">
    {% for item in tags %}
      <li><a href="{{item.Link}}">{{item.Title}} ({{item.ArchiveCount}} 篇文章)</a></li>
    {% empty %}
      <li>暂无可用标签。</li>
    {% endfor %}
  </ul>
{% endtagList %}

<div class="pagination-area">
  {% pagination pages with show="5" %}
    {# 此处添加分页导航的HTML结构,例如首页、上一页、中间页码、下一页、尾页等 #}
    <a class="{% if pages.FirstPage.IsCurrent %}active{% endif %}" href="{{pages.FirstPage.Link}}">{{pages.FirstPage.Name}}</a>
    {% if pages.PrevPage %}<a href="{{pages.PrevPage.Link}}">{{pages.PrevPage.Name}}</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}}">{{pages.NextPage.Name}}</a>{% endif %}
    <a class="{% if pages.LastPage.IsCurrent %}active{% endif %}" href="{{pages.LastPage.Link}}">{{pages.LastPage.Name}}</a>
  {% endpagination %}
</div>

In this example,item.ArchiveCountCan display the number of articles associated with the tag, helping users understand the popularity of the tag.

Displays the tag list of the specified article.

On the article detail page, you often need to display all the tags associated with the current article. AnQiCMS'stagListThe tag is very smart, when it is called in the document detail page, it will default get the current article ID throughitemIdAll labels under the automatically acquired parameters do not require you to manually specify the article ID.

Here is an example of an article detail page (for examplearticle/detail.html) where the current article tags are displayed.

<article class="article-detail">
  <h1>{{archive.Title}}</h1>
  <!-- 文章内容及其他信息 -->

  <div class="article-tags">
    <strong>相关标签:</strong>
    {% tagList tags with limit="10" %}
      {% for item in tags %}
        <a href="{{item.Link}}" class="tag-item">{{item.Title}}</a>
      {% empty %}
        <span>当前文章暂无标签。</span>
      {% endfor %}
    {% endtagList %}
  </div>
</article>

This code will automatically detect the article currently being viewed and list up to 10 tags associated with the article.When users click on these tags, they can jump to the details page of the tag to view all articles containing that tag.

Display Tag Details Information

When a user clicks on a tag, they will usually enter a dedicated tag detail page.On this page, you may need to display the detailed information of the tag itself, such as the tag name, description, and even a Logo related to the tag.tagDetailLabel to retrieve this information.

On a tag details page (usually corresponding to a template filetag/list.htmlortag/detail.html), you can obtain and display the tag details like this:

<section class="tag-header">
  {% tagDetail currentTag with name="Title" %}
    <h1>{{currentTag}}</h1>
  {% endtagDetail %}

  {% tagDetail tagDescription with name="Description" %}
    {% if tagDescription %}
      <p class="tag-description">{{tagDescription}}</p>
    {% endif %}
  {% endtagDetail %}

  {% tagDetail tagLogo with name="Logo" %}
    {% if tagLogo %}
      <img src="{{tagLogo}}" alt="{% tagDetail with name='Title' %}" class="tag-logo">
    {% endif %}
  {% endtagDetail %}
</section>

In this example,currentTag/tagDescriptionandtagLogoIt is defined as a variable for the label title, description, and Logo.tagDetailBy default, the label will automatically identify the label ID based on the current page's URL to obtain the corresponding detailed data.

Show the list of articles under the specified Tag

The core function of the tag detail page is to display all the articles tagged with that tag. To do this, you can usetagDataListThe tag is specifically used to retrieve the list of articles associated with the tag ID, and it supports pagination, sorting, and other functions.

The following is a typical usage of displaying the article list under the tag on the tag detail page:

<section class="tag-articles">
  <h2>“{% tagDetail with name="Title" %}”相关文章</h2>
  {% tagDataList archives with type="page" limit="10" order="views desc" %}
    <ul class="article-list">
      {% for item in archives %}
        <li>
          <a href="{{item.Link}}">
            <h3 class="article-title">{{item.Title}}</h3>
            <p class="article-description">{{item.Description|truncatechars:150}}</p>
            <div class="article-meta">
              <span>发布于: {{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
              <span>阅读量: {{item.Views}}</span>
            </div>
          </a>
        </li>
      {% empty %}
        <li>此标签下暂无文章。</li>
      {% endfor %}
    </ul>
  {% endtagDataList %}

  <div class="pagination-area">
    {% pagination pages with show="5" %}
      {# 此处添加分页导航的HTML结构 #}
      <a class="{% if pages.FirstPage.IsCurrent %}active{% endif %}" href="{{pages.FirstPage.Link}}">{{pages.FirstPage.Name}}</a>
      {% if pages.PrevPage %}<a href="{{pages.PrevPage.Link}}">{{pages.PrevPage.Name}}</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}}">{{pages.NextPage.Name}}</a>{% endif %}
      <a class="{% if pages.LastPage.IsCurrent %}active{% endif %}" href="{{pages.LastPage.Link}}">{{pages.LastPage.Name}}</a>
    {% endpagination %}
  </div>
</section>

In this example,tagDataListTag throughtype="page"Pagination feature is enabled,limit="10"Specify 10 articles to be displayed per page,order="views desc"then sorted in descending order by the number of page views of the articles.item.Link/item.Title/item.Description/item.CreatedTimeanditem.ViewsThe fields are used to display the detailed information of the article list.

By using these AnQiCMS built-in tags, you can flexibly and efficiently display and manage tags and their related content at various positions on the website, thereby enhancing the user experience and the overall content structure of the website.


Frequently Asked Questions (FAQ)

Why did I set the tag but it didn't display on the front-end page?

Answer: Please first check your AnQiCMS backend, make sure you have created and managed tags in "Content Management" -> "Document Tags".Next, when publishing or editing an article, confirm that the article has been correctly checked or entered with the corresponding tags.tagListortagDataListUse tags to call them. Finally, if your website has enabled caching, please try to update the system cache to ensure that the latest data is rendered.

How to set a friendly URL for tabs to benefit SEO?

Answer: AnQiCMS supports pseudo-static functionality, you can use "Function Management" -> "Pseudo-Static Rule" to define the URL structure of the tab page. Indesign-director.mdThe document mentions that the template path for the tag home page is usuallytag/index.html, the tag document list page istag/list.html. The pseudo-static rules can be configured in the background. For example, you can set the URL of the tag list page to/tags/{tagname}(-{page}).htmlor/tag/{id}(-{page}).htmlof which{tagname}or{id}It will dynamically generate a custom URL alias or ID based on the tag, which helps search engines better understand and crawl your tag page.

Ask: Can I display independent tag lists for articles of different content models?

Answer: Although AnQiCMS tags are shared across the entire site, they do not differentiate between content models (such as articles and products can share the same tag), but when calling the tag list,tagListandtagDataListThe tag itself does not directly support filtering bymoduleIdHowever, when displayingthe article list under a specific tagthen,tagDataListThe tag does supportmoduleIdThe parameter's. This means that you can display the list of articles under a specific tag bymoduleId="1"(article model ID) ormoduleId="2"(Product Model ID) to only display the content under the tag that belongs to a specific model. If you need to filter out tags that are only associated with a specific model article, you may need to make more advanced customization in the controller logic on the tag page or list page, or use the template.tagDataListFirst get the article, then extract the tags in reverse.

Related articles

How to retrieve the custom field parameters defined in the content model and filter and display them?

As an experienced CMS website operation person in an enterprise, I know how important the custom field function of the content model is for building rich and personalized website content.It can not only help us organize information flexibly, but also provide users with more accurate filtering and display experience.I will explain in detail how to obtain the custom field parameters of the content model definition in Anqi CMS and perform effective filtering and display. ### Create and manage custom content model fields Firstly, all functions are based on the configuration in the background.In AnQi CMS

2025-11-06

How to display a list of recommended articles related to the current article on the article detail page?

As an experienced security CMS website operator, I fully understand the importance of high-quality content and refined operation for user retention and website SEO.Display related recommended articles on the article detail page, which can not only effectively extend the user's time on the site and reduce the bounce rate, but also optimize through internal links, improve the overall weight of the website, and is an indispensable part of content operation.Below, I will give a detailed introduction on how to implement this feature in Anqi CMS.

2025-11-06

How can you easily obtain and display the link and title of the previous and next articles on the article detail page?

As an experienced website operator familiar with AnQiCMS, I fully understand the importance of effectively guiding users to browse and discover more content in content management.The navigation of the previous/next article on the article detail page not only can significantly improve user experience and prolong the time users stay on the site, but also helps to optimize the internal link structure of the website, which is very beneficial for SEO.I will elaborate in detail on how to conveniently and quickly obtain and display the links and titles of the previous and next articles on the article detail page of AnQiCMS.--- ###

2025-11-06

How to display the title, content, images, and other detailed information of the current content on an article or product detail page?

As a senior security CMS website operator, I know that the content detail page is a core component of the website, carrying the important mission of displaying key information such as products and articles to users.A well-designed, comprehensive detail page that not only effectively conveys content value but also enhances user experience and SEO performance.Strong and flexible template tags provided by Anqi CMS, allowing us to easily control the display of each item on the page.

2025-11-06

How to get and display the list of all documents under a specific Tag tag?

As a website operator who deeply understands the operation of AnQiCMS, I fully understand the importance of efficient content management and optimization.Tags (Tag) are one of the key elements for organizing content, improving user experience, and enhancing SEO performance.By using tags, we can not only provide readers with more accurate content aggregation, but also help search engines better understand the structure of the website content.I will elaborate in detail on how to retrieve and display the list of all documents under a specific Tag label in AnQiCMS.

2025-11-06

How to retrieve and display the website's comment list, including multi-level replies?

As a website content expert who deeply understands the operation of Anqi CMS, I am well aware of the readers' needs for interactivity and information transparency.The comment feature is an important way for users to participate in website content construction and express their opinions, and multi-level replies can effectively promote in-depth communication between users.AnQi CMS provides us with a powerful and flexible comment management mechanism, making it efficient and convenient to retrieve and display comment lists, including multi-level replies.

2025-11-06

How to embed and display a user留言表单in a template?

As a website operator who deeply understands the operation of AnQiCMS, I fully understand the importance of providing user interaction channels on the website.The user feedback form is a key tool for collecting feedback, answering questions, and building relationships with users.In AnQiCMS, embedding and displaying a comment form through its flexible template engine is a direct and highly customizable process.This article will detail how to implement this feature in the AnQiCMS template.

2025-11-06

How to retrieve and display the list of友情链接 configured in the background?

As an experienced CMS website operation personnel, I fully understand the importance of efficient content management and front-end display for the success of the website.Friend links are an important part of a website's external cooperation and SEO optimization, and their convenient acquisition and display methods are an indispensable part of daily operation.Now, I will elaborate on how to obtain and display the list of友情链接 links configured in the AnQiCMS admin panel.### AnQi CMS: Efficient management and display of the background friendship link list Friendship links, as an important part of website external link construction

2025-11-06