How to display the Tag list of articles and detailed information of a single Tag as well as associated documents in AnQiCMS?

Calendar 👁️ 60

In a content management system, how to effectively organize and display content is the key to improving user experience and search engine friendliness.AnQiCMS provides a powerful Tag feature that helps us classify and display content more accurately.This article will provide a detailed introduction on how to flexibly use tags in AnQiCMS, including displaying tag lists, viewing detailed information of individual tags, and listing documents associated with specific tags.

The role of tags in AnQiCMS

In AnQiCMS, tags are a flexible content organization method, different from the traditional category (Category).Categories usually represent the hierarchical structure of content, while tags are more focused on the keywords or thematic associations of the content.By adding tags to articles, we can achieve:

  • Enhance the discoverability of content: Users can quickly find all related topic articles by clicking on the tags.
  • Optimize SEO: The tab can serve as a long-tail keyword landing page, helping search engines better understand the content of the website.
  • Improve user experience:to provide users with multi-dimensional content navigation, improving the interactivity and stickiness of the website.

In the AnQiCMS backend, you can conveniently manage all tags.Enter the "Document Tag" feature under "Content Management" to perform add, edit, and delete operations.Each tag has a name, index letter, description, custom URL, and SEO-related settings, all of which provide convenience for front-end display and search engine optimization.

Display the tag list on the website.

To display the tag list at any location on the website (such as the sidebar, article footer, or a dedicated tag cloud page), AnQiCMS providestagListLabel. This label is very flexible and can display various types of label collections according to different needs.

For example, if you want to display the top 10 tags on your website, you can use the following methodtagList:

<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,tagsis the variable name we define,limit="10"It limited to only displaying 10 tags. EachitemincludesId/Title(Tag name) andLink(Tag page link) and other commonly used information, which can be called as needed.

In addition, when you need to display all the tags associated with the current article on the article detail page,tagListit can also be useful. At this time, you can useitemIdThe parameter allows the tag list to only display tags related to the current document:

<div>
    <strong>文章标签:</strong>
    {% tagList tags with itemId=archive.Id limit="10" %}
    {% for item in tags %}
    <a href="{{item.Link}}">{{item.Title}}</a>
    {% endfor %}
    {% endtagList %}
</div>

here,archive.IdIt will automatically retrieve the ID of the current article to ensure that the displayed tags are unique to the current article.

Display detailed information of a single tag

When a user clicks on a tag, they will usually enter a dedicated tag detail page.On this page, we may need to display the title, description, and other detailed information of the tag to tell the user the theme of the current page.AnQiCMS providedtagDetailTag to get all related data of a single tag.

Generally, intag/detail.htmlortag/index.html(If designed to use this template for all tag lists and individual tag details) such a template file,tagDetailwill automatically retrieve the tag ID of the current page.

<main>
    <h1>{{ tagDetail with name="Title" }}</h1>
    {%- tagDetail tagDescription with name="Description" %}
    {%- if tagDescription %}
    <p>{{ tagDescription }}</p>
    {%- endif %}
    <p>该标签下共有 {{ tagDataList archives with type="list" limit="1" %}{{ archives|length }}{% endtagDataList }} 篇文章。</p>
</main>

In the code above,tagDetail with name="Title"The title of the current tag was directly output,tagDescription with name="Description"Then the description of the tag was retrieved and passed through,ifEnsure that the description is displayed when it is available to avoid blank tags on the page. You can also get theId/Link/FirstLetter(index letter) andLogofields.

display the documents associated with the tag

On the tag detail page, the most core function is of course to display all articles or products with this tag. AnQiCMS'stagDataListTags are specifically used for this purpose. They can retrieve and display all associated documents based on the tag ID and support pagination features to make content display more friendly.

In the template of the label detail page, you can use it like thistagDataListto display the related article list:

<section>
    <h2>相关文章列表</h2>
    <ul>
    {% tagDataList archives with type="page" limit="10" %}
        {% for item in archives %}
        <li>
            <a href="{{item.Link}}">
                <h3>{{item.Title}}</h3>
                <p>{{item.Description|truncatechars:100}}</p>
                <span>发布时间: {{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                <span>阅读量: {{item.Views}}</span>
            </a>
            {% if item.Thumb %}
            <img src="{{item.Thumb}}" alt="{{item.Title}}">
            {% endif %}
        </li>
        {% empty %}
        <li>该标签下暂无文章。</li>
        {% endfor %}
    {% endtagDataList %}
    </ul>

    {# 分页导航 #}
    <nav class="pagination">
        {% pagination pages with show="5" %}
            {% if pages.PrevPage %}<a href="{{pages.PrevPage.Link}}">上一页</a>{% endif %}
            {% for page in pages.Pages %}<a class="{% if page.IsCurrent %}active{% endif %}" href="{{page.Link}}">{{page.Name}}</a>{% endfor %}
            {% if pages.NextPage %}<a href="{{pages.NextPage.Link}}">下一页</a>{% endif %}
        {% endpagination %}
    </nav>
</section>

here,tagDataListAutomatically identify the ID of the current label page and list the relevant articles in a pagination format(type="page"andlimit="10")archivesEach variable containsitemthe content of the articleId/Title/Link/Description/Thumb(thumbnail),CreatedTime(Publishing time) andViews(Reading volume) and other information. The bottompaginationtags are responsible for generating beautiful pagination links, allowing users to easily browse all related content.

BytagList/tagDetailandtagDataListThese three core tags provide comprehensive and powerful support for the AnQiCMS content tagging and display management, helping the website to better organize content and improve user experience and search engine performance.


Frequently Asked Questions (FAQ)

  1. Ask: What is the difference between tags and categories? How should I choose to use them?Answer: Tags and categories are both ways to organize content, but they have different focuses.Categories are usually used to build the hierarchical structure of a website, and content is strictly attributed to one or more categories.And tags are more like keywords or themes of content, a piece of content can be marked with multiple tags, and tags usually do not have a hierarchical relationship.When selecting, you can use core, broad topics as categories, and more specific, flexible keywords as tags to provide multi-dimensional content navigation.

  2. Ask: Can the URL structure of the AnQiCMS tag page be customized?Answer: yes. AnQiCMS provides a powerful pseudo-static rule setting feature.In the background feature management, find the "pseudo-static rules", you can choose or customize the URL structure of the label page.For example, the default structure may containtag/index.htmlortag/list.htmlBut you can use custom rules to make your URL more descriptive or more SEO-friendly, for example/tags/{tagname}.htmlor/topic/{id}.htmlEtc. In the tag background settings, each tag can also be set to a custom URL alias.

  3. Question: Why did I set a tag, but it did not display on the front-end page?Answer: There are several common reasons why the label may not be displayed:

    • Missing or incorrect template codePlease check your template file (such asbash.html/tag/index.htmlorarchive/detail.htmletc.) to see if it has been used correctlytagList/tagDetailortagDataListLabel, make sure the variable names, parameters, and so on are spelled correctly.
    • Label is not associated with contentIf you expect:tagListDisplay the tags of an article, but if the article has not been added any tags, it will not be displayed naturally. Or, if there are no associated documents under a certain tag, thentagDataListit will also be displayed as empty.
    • Cache issueAfter modifying in the background, please try to clear the system cache and clean the browser cache to ensure that the latest content is loaded.
    • Permission or publishing statusMake sure the tag itself is not disabled and all associated articles are published.

Related articles

How does AnQiCMS's 'Document Parameter Filtering' feature help users perform combined filtering of content lists on the front end?

Today, with the rich content of websites, how to help visitors quickly and accurately find the information they are interested in has become a key challenge in content operation.Imagine if your website had thousands of articles, products, or cases, and visitors could only filter through them with simple categorization and search, it would undoubtedly greatly reduce their exploration efficiency and satisfaction.AnQiCMS is well-versed in this field and has provided us with a highly efficient and flexible solution - the "document parameter filtering" feature.This feature is like an intelligent guide, able to meet various conditions we preset

2025-11-08

How to loop through custom parameters of articles in a template (such as author, source)?

In AnQi CMS, flexibly displaying customized article parameters is the key to enhancing the personalization and information richness of the website content.In order to better describe product features, or to clearly mark the author and source in an article, custom parameters can provide strong support.The AnQi CMS provides a simple and efficient way to define and call these parameters, allowing you to easily display them in website templates. Next, we will step by step discuss how to implement the loop display of article custom parameters in Anqi CMS template.### Step 1

2025-11-08

How does AnQiCMS display a list of recommended content related to the current article?

In content management and website operations, how to effectively attract visitors, extend their stay on the website, and guide them to discover more interesting content is a crucial issue.AnQiCMS (AnQiCMS) provides a powerful and flexible mechanism that helps us easily display a list of related recommended content on the current article page, thereby greatly enhancing the user experience and the overall performance of the website.**Core Mechanism: `archiveList` tag's `type="related"` attribute** AnQiCMS

2025-11-08

How to display the title and link of the 'Previous' and 'Next' articles on the article detail page?

In website content operation, the navigation design of the article detail page is crucial.A well-designed user experience detail page that can clearly present the current content and naturally guide readers to browse more related or coherent articles.The display of the 'Previous' and 'Next' articles is a classic approach to enhance user stickiness and the efficiency of the website's internal link structure.AnqiCMS is an enterprise-level content management system developed based on the Go language, which fully considers the efficiency and flexibility of content management from the beginning of its design.It relies on a concise and efficient architecture

2025-11-08

How does AnQiCMS display the website message form and customize the form field display?

AnQi CMS: Flexible display and field customization of the website message form In website operation, the message form is an important bridge connecting users and the website.Whether it is to collect customer feedback, provide consulting services, or interact with users, a well-functioning and easy-to-use comment form is particularly important.AnQiCMS (AnQiCMS) is well-versed in this field, providing users with a powerful and flexible feedback form feature, which can be easily displayed on the website front-end and supports in-depth customization of form fields to meet various business needs.### One,

2025-11-08

How to display the friend link list at the bottom of the AnQiCMS website?

In website operation, friendship links play an indispensable role.It is not only an effective way for websites to recommend and share traffic with each other, but also an important means to enhance the weight and visibility of websites in search engines.However, how to conveniently manage and display these links on a website is a practical problem faced by many website managers.AnQiCMS as a system focusing on enterprise-level content management and SEO optimization, provides an intuitive link function and a flexible template calling mechanism, making this process extremely simple.###

2025-11-08

How to apply AnQiCMS pagination feature to the pagination display of article lists or Tag document lists?

In website content management, whether it is to display a large number of articles, products, or documents under categories, an efficient and user-friendly pagination function is crucial.It not only allows users to easily browse a large amount of content, avoid the slow loading caused by long pages, but also helps search engines better crawl and index website information.AnQiCMS is well-versed in this, providing intuitive and powerful pagination functions in template tag design, making it effortless to implement pagination display in article lists or Tag document lists.Understanding how AnQiCMS implements pagination

2025-11-08

How to use if/for tags in a template to control the conditional display and looping display of content?

When building and operating a website, the dynamic display and flexible management of content are key to improving user experience and operational efficiency.AnQiCMS (AnQiCMS) understands this point, therefore its template engine provides powerful and intuitive conditional judgment (`if`) and loop traversal (`for`) tags, allowing you to easily control the display logic of content and achieve highly customized page layouts.The template syntax of AnQi CMS borrows the concise style of Django template engine, with a very low learning cost.By mastering these core tags

2025-11-08