How to display the Tag tags and associated documents on the AnQiCMS front-end page?

Calendar 👁️ 68

In AnQiCMS, effectively utilizing the tag function is a key factor in improving website content organization, optimizing user experience, and enhancing search engine visibility.Tags can not only help users quickly find the content they are interested in, but also provide website administrators with flexible content classification and association methods, breaking through the hierarchical constraints of traditional classification.

AnQiCMS's tag feature is powerful and flexible, allowing content creators to add descriptive keywords or phrases to articles and products.These tags can be conveniently created, edited, and managed in the background admin, and can be easily selected or added when publishing articles.Once the content is tagged, we can use the built-in template tags of AnQiCMS on the front page to accurately display these tags and their associated content.

Display the current article's tags on the article detail page

When a visitor browses a specific article, they usually want to see tags related to the content of the article so that they can further explore content on the same topic. In AnQiCMS, you cantagListThe tag easily achieves this.

This tag is usually used on article detail pages (for examplearchive/detail.htmlOr custom article template), it will intelligently retrieve all the tags associated with the current article.You do not need to manually specify the article ID, as it will be automatically recognized in the context of the article detail page.

For example, if you want to display all related tags below the article content, you can write the template code like this:

{# 假设这是文章详情页模板的一部分 #}
<div class="article-tags">
    <strong>标签:</strong>
    {% tagList tags %} {# 默认获取当前文档的标签 #}
        {% for item in tags %}
            <a href="{{item.Link}}" title="{{item.Title}}">{{item.Title}}</a>
        {% endfor %}
    {% endtagList %}
</div>

This code will traverse all the tags associated with the current article and generate clickable links for each tag, linking to the tag's detail page, making it convenient for users to click and view more related articles.

Create an independent tag list page

To enable users to find all tags on the website, you may need to create a separate tag list page, like a 'tag cloud' or 'tag index'. In AnQiCMS, template files are usually named astag/index.htmlTo bear this kind of page.

On this page, we also usetagListtags, but this time no specific tags are specified.itemIdParameters, so it will retrieve all the tags of the entire website. You can set it as neededlimitParameters to control the number of tags displayed

For example, create a page that displays all tags:

{# tag/index.html 模板文件内容示例 #}
<h1>所有标签</h1>
<div class="tag-cloud">
    {% tagList tags with limit="100" %} {# 获取网站前100个标签 #}
        {% for item in tags %}
            <a href="{{item.Link}}" title="{{item.Title}}">{{item.Title}} ({{item.ArchiveCount}}){# 假设你想显示每个标签的文章数量 #}</a>
        {% endfor %}
    {% endtagList %}
</div>

Hereitem.ArchiveCountalthough intag-archiveTag.mdofitemThe field is not directly listed, but in actual use, many CMS tag objects may contain the number of associated content. If not supported, it can be ignored.Here is an example of how to expand the display information.

Through such a page, users can clearly see all the topics covered by the website and can click to enter the detailed page of a specific tag.

Create tag detail pages and display related articles

When a user clicks on a specific tag (whether from an article detail page or a tag list page), they expect to see the details of the tag as well as all articles associated with the tag. In AnQiCMS, such pages are usually handled bytag/list.htmlThe template file is responsible for rendering.

On this page, we will use two core tags:

  1. tagDetailTag: Used to obtain the detailed information of the tag itself on the current page, such as the tag name, description, etc. You do not need to specify the ID, as it will automatically identify the tag ID of the current page.

  2. tagDataListTagIt is used to get all articles associated with the current tag. It automatically identifies the page of the current tag.tagIdand can be combined withtype="page"andpaginationtags to implement pagination display of associated articles.

The following is an example of a label detail page template code

`twig {# tag/list.html template file content example #} {% tagDetail currentTag %} {# Get the details of the current tag #}

<h1>标签:{{currentTag.Title}}</h1>
{% if currentTag.Description %}
    <p>描述:{{currentTag.Description}}</p>
{% endif %}

{% endtagDetail %}

Related articles

How to customize the URL alias of the document and ensure the uniqueness of the front-end link?

The custom document URL alias is an indispensable detail in website operation, it not only concerns the SEO performance of the website, but also directly affects user experience and brand image.In AnQiCMS, you have powerful flexibility to manage these aliases and ensure their uniqueness in frontend links. ### Flexibly define, make URLs more meaningful Imagine, which one is easier to remember and share, a chaotic, disordered URL made up of numbers and symbols, or a clear, meaningful URL that directly reflects the theme of the content?

2025-11-08

How to extract and display the first image in the document content as a thumbnail?

In website operation, it is a key to enhance click-through rate and optimize user experience to equip each article or product with an attractive thumbnail.However, manually creating and uploading thumbnails for a large amount of content will undoubtedly take a lot of time and effort.Our company, AnQi CMS, is well-versed in this field and provides us with an intelligent and efficient thumbnail processing solution, making website content management easier. ### The Intelligent Thumbnail Mechanism of AnQi CMS The thumbnail processing mechanism of AnQi CMS is very user-friendly.

2025-11-08

How to optimize the display and lazy loading of images and videos in document content?

In today's content-driven internet environment, images and videos have become key elements in attracting users and enhancing page interaction.However, they are often the main culprits that lead to slow website loading and a decline in user experience.As users of AnQi CMS, we are fortunate to have a powerful and flexible system that not only efficiently manages content but also has many built-in features to help us cleverly optimize the display of images and videos, and realize smart lazy loading, so that the content can also 'fly' while ensuring visual effects.

2025-11-08

How to filter and display a specific content list based on the 'recommended properties' of the document?

How to effectively organize and display a large amount of content when operating a website is the key to improving user experience and content value.AnQiCMS provides a very practical feature, that is, to refine the management and filtering of content lists through 'recommended attributes'.This not only makes the website content more dynamic, but also helps visitors find the information they are interested in more quickly.### Understanding "Recommended Properties": A Tool for Content Organization In Anqi CMS, when we publish or edit documents, we will find an option called "Recommended Properties"

2025-11-08

What is the difference between SEO title and document title? Where do they show up?

In website operation, we often encounter the concepts of content title and SEO title.Although they are all related to the 'title', there is a clear and important distinction between them in terms of actual application and display location.Understanding and effectively using these two things is the key to making website content both attractive to visitors and favored by search engines.

2025-11-08

How to configure and display custom Banner images and thumbnails for the AnQiCMS category page?

AnQiCMS (AnQiCMS) provides us with very flexible content management capabilities, one very practical feature is that it can configure and display custom Banner images and thumbnails for category pages.This not only makes our website look more professional and beautiful, but also effectively improves the user experience and the efficiency of content organization.Why does the category page need a custom Banner image and thumbnail?

2025-11-08

How does the inheritance mechanism of the category template affect the content display of the subcategory page?

The inheritance mechanism of AnQi CMS category templates: How to balance the consistency of page content and personalized displayAnQi CMS deeply understands this, and its inheritance mechanism of classification templates is specifically designed to help us cleverly solve this problem.

2025-11-08

How to dynamically display content on the AnQiCMS document list page through filtering conditions?

How to make users more efficiently find and browse content in website operation is the key to improving user experience and website value.Especially for document list pages, if a flexible filtering function can be provided, allowing users to dynamically adjust the display of content according to their needs, it will undoubtedly greatly enhance the interactivity and usability of the website.AnQiCMS with its flexible content model and powerful template tag features can easily meet this requirement.

2025-11-08