How to display a list of commonly used tags on a website or tags of specific documents?

Calendar 👁️ 71

In AnQiCMS, efficiently manage and display website tags, which can not only help users find the content they are interested in faster, but also effectively improve the website's SEO performance.Tags as a flexible content classification method can associate content spanning different categories and even different models, forming a content matrix.Below, we will start from several common application scenarios and explain in detail how to display the list of commonly used tags on your website, as well as how to display the associated tags for specific documents.

The importance of tags

In AnQiCMS, tags are a powerful content management tool.They allow you to attach keywords to articles, products, or other content types, which can be independent of the traditional classification structure.Tags provide a convenient way for users to discover related content.For search engine optimization (SEO), tabs can create more themed pages, increase the internal links of the website, and help search engines better understand the structure of the website content.

One, display the list of commonly used website tags (such as in the sidebar, footer, or tag aggregation page)

You may wish to display popular or recently published tags on a prominent location of the website, such as the sidebar, footer, or a dedicated 'tag cloud' page.This helps users quickly browse the core content themes of the website.

In AnQiCMS, you can usetagListtags to easily meet this need.

1. Get the site-wide common tags

If you want to display the most popular or latest tags across the entire site, you can usetagListtags and setitemId="0"Get it.limitparameter to control the number of tags displayed.

<div class="tag-cloud">
    <h3>热门标签</h3>
    <ul>
        {% tagList tags with limit="20" itemId="0" %}
            {% for item in tags %}
                <li><a href="{{ item.Link }}" title="{{ item.Title }}">{{ item.Title }}</a></li>
            {% empty %}
                <li>暂无标签可显示。</li>
            {% endfor %}
        {% endtagList %}
    </ul>
</div>

Code description:

  • {% tagList tags with limit="20" itemId="0" %}This line of code tells the system that we want to get a list of tags and store it in a namedtags.limit="20"This indicates that we only display 20 tags.itemId="0"It is the key here, it explicitly indicates that the system should retrieve *all* available tags, not just those related to the current page.
  • {% for item in tags %}: This is a loop structure, it will traversetagsEach tag contained in the variable.
  • {{ item.Link }}: In the loop,itemThe variable represents the current tag.item.LinkIt will output the URL address corresponding to the tag.
  • {{ item.Title }}:item.TitleThen it will output the name of the tag.
  • {% empty %}If:tagsIf there are no tags in the list, it will display.{% empty %}and<li>暂无标签可显示。</li>The content between.
  • </div>The tag wraps the entire tag list, you can place it anywhere on the page according to your website design, such as the public sidebar template file (partial/sidebar.html) or the footer (partial/footer.html).

2. Integrate the tag list into the template

To maintain the modularity and reusability of the code, it is recommended to save the above tag list code snippet as a separate template file, for examplepartial/common_tags.htmlThen, in your main template file (such asindex.htmlorbase.html) or any place where you need to display common tags, useincludeLabel it to introduce:

{# 在您的主模板文件(例如 index.html 或 base.html)中 #}
<div class="main-content">
    {# ... 您的主要内容 ... #}
    <aside class="sidebar">
        {% include "partial/common_tags.html" %}
    </aside>
</div>

This way, you can easily update or adjust the display of the tag list without modifying the main template structure.

II. Display tags of specific documents (such as in the article detail page)

On the article or product detail page, displaying tags directly related to the current document is an important way to enhance user experience and content relevance.Users can click on these tags to explore more content on the same topic.

Similarly, we still usetagListtags, but this time the usage is a bit different.

1. Get the current document tag

When you are on the detail page of a document,tagListThe tag will try to retrieve the tags associated with the current document, no explicit specification is requireditemIdBut in order to clarify the code and avoid potential ambiguity, we can also explicitly pass the ID of the current document toitemIdParameter.

Assuming you are currently viewing a document and the details of the document are stored in a variable namedarchive(which is usually obtained after usingarchiveDetailtag), you can display the label as follows:

<div class="article-tags">
    <strong>标签:</strong>
    {% tagList tags with itemId=archive.Id limit="10" %}
        {% for item in tags %}
            <a href="{{ item.Link }}" class="tag-link">{{ item.Title }}</a>
        {% empty %}
            <span>该文档暂无标签。</span>
        {% endfor %}
    {% endtagList %}
</div>

Code description:

  • {% tagList tags with itemId=archive.Id limit="10" %}: Here,

Related articles

How to implement filtering conditions based on document parameters and display the filtering results?

In AnQiCMS (AnQiCMS), using document parameters to build flexible filtering conditions and display the filtering results is a key factor in improving website user experience and content management efficiency.This not only helps users find the information they need faster, but also makes the website's content structure clearer.This article will introduce you to how to implement this feature in AnQi CMS, from the initial parameter definition to the final filtering and display, helping you easily master content management.## Make content smarter: How to cleverly use document parameters to implement filtering function in Anqi CMS As the content of the website continues to enrich

2025-11-08

How to display custom parameters on an article or product detail page?

In website operation, adding personalized information to articles or product detail pages is the key to improving content professionalism and user experience.AnQiCMS (AnQiCMS) fully understands this need and provides powerful customizable parameter functions, allowing us to flexibly add and display the required information according to different content types. Imagine you publish a technical article, in addition to the title and content, you also want to display unique attributes such as "author", "publish date", "technology stack", and so on; Or maybe, you are selling a product, in addition to the usual name, price, and description, you also want to highlight the "color"

2025-11-08

How to display a list of related articles below the article detail page?

In website operation, the list of "related articles" at the bottom of the article detail page is an important function to enhance user experience, increase page views (PV), and prolong the time users stay on the site.It can guide users to discover more interesting content, thereby enhancing the overall stickiness of the website, and also has a positive effect on search engine optimization (SEO).To implement this feature in AnQi CMS, it benefits from its flexible template system and powerful tag functions, making the entire process intuitive and efficient.### One, understand the call mechanism of "related articles" The template tags of AnQi CMS are the core of realizing various functions

2025-11-08

How to display the links to the previous and next articles on the document detail page?

When browsing website content, users often want to be able to navigate easily between related articles.For example, after reading a news article or tutorial, you can quickly click to go to the "previous" or "next" article to maintain the continuity of reading.This not only improves user experience and reduces the bounce rate, but also has a positive effect on the internal link structure of the website and search engine optimization (SEO).AnQiCMS (AnQiCMS) is an efficient content management system that provides a very simple and intuitive way to implement this function.We do not need complex backend programming

2025-11-08

How to retrieve and display detailed descriptions and associated documents for a specific tag?

In content management, tags are a powerful and flexible tool that helps us organize website content more finely, improve user experience, and optimize search engine rankings.AnQiCMS fully understands this, providing intuitive and feature-rich template tags that allow you to easily obtain and display detailed descriptions of specific tags and their associated documents.This article will delve into how to use these tags in the AnQiCMS template to make your website content more relevant and discoverable.### Understand the tags in AnQiCMS In

2025-11-08

How to display the user comment list below the article page?

In website operation, user comments are an important aspect for enhancing content interaction, strengthening community atmosphere, and optimizing search engine rankings (SEO).AnQiCMS provides a flexible and powerful template tag system, making it easy and convenient to integrate a user comment list and comment form at the bottom of the article page.This article will provide a detailed introduction on how to elegantly display user comments on the article detail page of AnQi CMS, and also provide a function for users to submit comments.

2025-11-08

How to integrate and display a friend link list on a website?

In website operation, friendship links play an indispensable role. They are not only the bridges to establish contact with other websites but also effective ways to improve website authority, obtain external traffic, and enhance user experience.AnQiCMS as an efficient and flexible content management system provides an intuitive and convenient solution for the integration and display of friend links. ### First Part: Admin Friend Links One of the design philosophies of AnQiCMS is to make website operation more efficient, and the management of friend links is naturally integrated very well.

2025-11-08

How to correctly display pagination navigation for articles or category lists?

When managing website content, whether it is an article list, product display, or other category pages, a clear and effective pagination navigation is crucial for improving user experience and search engine optimization.AnQiCMS (AnQiCMS) provides powerful template tag features, allowing us to easily add correct pagination navigation to the list page.This article will introduce how to implement this feature in AnQi CMS.

2025-11-08