How to display the Tag tag list of articles or products in AnQiCMS?

Calendar 👁️ 75

In Anqi CMS, flexibly displaying the Tag tag list of articles or products is a key link to improving the organization of website content and user experience.By carefully designed tags, not only can it help visitors quickly find the content they are interested in, but it can also effectively optimize search engine crawling and improve the SEO performance of the website.Today, let's delve deeper into how to make full use of the Tag feature in AnQiCMS, bringing new vitality to your website content.

Understanding the Tag tag in AnQiCMS

In the AnQiCMS management backend, the Tag tag feature is designed to be very intuitive and powerful.It is independent of the traditional classification system, providing another flexible way to categorize content, somewhat similar to the 'topics' in social media.No matter whether you are publishing an article or a product, you can easily add one or more Tag tags in the edit interface.

You can find the 'Document Tag' option under the 'Content Management' menu in the backend, where all the Tag tags of your website are collected.Here, you can create, edit, or delete tags, and even set independent SEO titles, keywords, and descriptions for them, which is crucial for the SEO value of building tag aggregation pages.

Display Tag list on the front-end

There are several common scenarios for displaying Tag labels on the front-end of the website, and we will discuss their implementation methods one by one.

1. Show all Tag tag list (e.g., Hot Tag Cloud)

Imagine that you want to display a popular tag cloud in the sidebar, footer, or a dedicated tag aggregation page of your website, so that visitors can see all the main topics covered by the website at a glance. At this time, you can use the AnQiCMS providedtagListthe tag.

To display all tags, you can write the template code like this:

<div class="tag-cloud">
    {% tagList tags with limit="50" itemId="0" %}
        {% for item in tags %}
            <a href="{{item.Link}}" title="{{item.Title}}">{{item.Title}}</a>
        {% endfor %}
    {% endtagList %}
</div>

In this code block:

  • tagList tagsDefined a namedtagsvariable to store the list of tags obtained.
  • limit="50"Limited to displaying up to 50 tags. You can adjust this number according to your actual needs.
  • itemId="0"It is a very important parameter, it tells the system to retrieve all tags on the website, not tags under a specific article or product.
  • By{% for item in tags %}Loop, we can iterate over each tag.
  • {{item.Link}}It will output the URL of the aggregated page corresponding to the tag.
  • {{item.Title}}It displays the name of the tag.
  • {{item.Description}}(If the tag is set) it can be used astitlea property or displayed elsewhere to provide more information.

This code is usually placed in the sidebar of your theme template file (for examplepartial/aside.html) or the footer (partial/footer.html), or it can be a dedicated tag list page.

2. Show specific article or product Tag tags

When visitors browse specific articles or product detail pages, they usually want to see tags related to the current content.This helps them find more similar topics or products. In AnQiCMS, you can use the template again on the article or product detail page.tagList.

For example, in your{模型table}/detail.html(such asarticle/detail.htmlorproduct/detail.htmlIn the template, you can add it like this:

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

You will notice that heretagListthe tag does not specifyitemIdthe parameter. This is because in the context of an article or product detail page,tagListAutomatically fetches the associated Tag tags of the current page's articles or products, very convenient.

3. Display the list of articles or products under a specific Tag tag

When a user clicks on a Tag, it usually jumps to a special page that displays all articles or products with that tag. This page is usually corresponding to the template structure in AnQiCMS.tag/list.html. We need to use it to display content on this pagetagDataList.

At the same time, in order to make this page more perfect, we will also usetagDetailTag to get the detailed information of the current tag (such as title, description), as well aspaginationTag to handle the pagination display of content.

Before yourtag/list.htmlIn the template, you can build it like this:

{# 获取当前Tag标签的详细信息 #}
<h1 class="tag-title">{% tagDetail with name="Title" %}</h1>
<div class="tag-description">{% tagDetail with name="Description" %}</div>

{# 展示该Tag标签下的文章或产品列表 #}
<ul class="tag-content-list">
    {% tagDataList archives with type="page" limit="10" %}
        {% for item in archives %}
            <li>
                <a href="{{item.Link}}">
                    <img src="{{item.Thumb}}" alt="{{item.Title}}" class="content-thumb">
                    <h3>{{item.Title}}</h3>
                    <p>{{item.Description}}</p>
                    <span class="publish-date">{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                </a>
            </li>
        {% empty %}
            <li>
                当前标签下没有任何内容。
            </li>
        {% endfor %}
    {% endtagDataList %}
</ul>

{# 分页导航 #}
<div class="pagination-area">
    {% pagination pages with show="5" %}
        {% if pages.PrevPage %}
            <a href="{{pages.PrevPage.Link}}" class="page-link">&laquo; 上一页</a>
        {% endif %}
        {% for item in pages.Pages %}
            <a href="{{item.Link}}" class="page-link {% if item.IsCurrent %}active{% endif %}">{{item.Name}}</a>
        {% endfor %}
        {% if pages.NextPage %}
            <a href="{{pages.NextPage.Link}}" class="page-link">下一页 &raquo;</a>
        {% endif %}
    {% endpagination %}
</div>

Here:

  • {% tagDetail with name="Title" %}and{% tagDetail with name="Description" %}It will directly output the title and description of the current tab.
  • tagDataList archivesUsed to get the list of articles or products associated with the current tag.
  • type="page"Means enabling pagination feature.
  • limit="10"Sets the display of 10 items per page.
  • {{item.Link}}/{{item.Title}}/{{item.Thumb}}and{{item.Description}}Correspond to the link, title, thumbnail and introduction of the content item.
  • {% empty %}The block will display a custom prompt when there is no content.
  • {% pagination pages %}The tag is responsible for generating beautiful pagination links.

Template file and URL structure hint

To make the above code run correctly on your website, you need to ensure that there is a corresponding Tag tag template file in your theme template. Usually:

  • /template/您的主题目录/tag/index.html: Can be used as an overview page for all tags.
  • /template/您的主题目录/tag/list.html: Used to display the content list under a specific tag.

In addition, AnQiCMS supports static URLs, which makes the URL structure of Tag tags very friendly to display for search engines and users. For example, a tag's URL might look like/tag-ID.htmlor/tags/标签别名.htmlThis helps improve the SEO performance of the tag page.

Summary

The Tag label feature of AnQi CMS not only provides a flexible content organization method, but also enables content operators to easily display a diverse list of labels on the front end with powerful template tags.Whether it is to build a hot tag cloud, display related tags of articles, or create a tag aggregation page, AnQiCMS can provide intuitive and efficient solutions.Mastering the use of these tags will make your website content more structured, easier for users to explore, and thus improve the overall user experience and SEO effectiveness.


Frequently Asked Questions (FAQ)

1. What is the difference between Tag tags and categories? How should I choose to use them?

Tag labels and categories are both ways to organize content, but they have different purposes and granularity. Categories (Category) usually represent the content of the websiteoutline or thematic structure,has a hierarchical relationship, for example, "news", "products", "tutorials", etc., each article generally belongs to only one main category. While Tag tags are more focused on the content of thespecific keywords, features or topicsCan cross categories, an article can have multiple Tag tags.For example, an article about 'AnQi CMS installation tutorial' can belong to the 'Tutorial' category, and can also be tagged with 'Installation', 'Go language', 'CMS', 'Deployment', and other tags.When making a selection, if the content is structurally belong, tend to use classification;If it is a keyword or a topic related across domains, it is more suitable to use Tag tags.

2. How to make the URL of the Tag tag page more SEO-friendly?

AnQiCMS supports default pseudo-static URLs, which is very important for the SEO of Tag tag pages. You can find it in the background of the “

Related articles

How does the new content model feature enhance the flexibility of content display?

In today's rapidly changing digital world, the content carried by websites is no longer just simple articles and product introductions.From an exciting online event, a detailed customer case, to a professional team introduction, and a complex service process, each type of content has its unique attributes and presentation methods.If your content management system (CMS) still only uses the universal templates of "article" or "product" to publish all information, it will undoubtedly bring many limitations to content creation and display.

2025-11-08

How to configure website adaptive display on different devices (PC, mobile)?

In the era of the prevalent mobile Internet, whether a website can provide a smooth and beautiful browsing experience on different devices (whether it is a large screen PC or a small mobile phone) has become a key factor in measuring whether a website is successful or not.AnQiCMS knows this pain point and provides flexible and powerful adaptive display configuration capabilities to help your website easily navigate the multi-screen world. AnQiCMS divides the adaptive display methods of websites into three main modes, you can choose the most suitable solution according to your business needs and technical preferences.

2025-11-08

What are the basic syntax rules of the AnQiCMS template engine used to display content?

AnQiCMS provides a user-friendly and powerful template engine, its design philosophy is to make the display of website content both flexible and easy to use.If you are familiar with template syntax like Django or Blade, then AnQiCMS's template engine will be very familiar to you.It is committed to presenting complex backend data in a clear and readable manner on the website front end, allowing content managers to focus on content creation and optimization rather than getting lost in the details of the code.

2025-11-08

How can you use the scheduled publishing feature to precisely control the display time of content on the website?

In the daily work of content operation, the timing of content release is often closely related to the communication effect, user reach, and overall activity of the website.It is particularly important to control the display time of content on the website accurately, whether it is to cater to the peak of user activity, cooperate with marketing activities, or simply to maintain the regularity of website updates.Anqi CMS knows this point, therefore it has specially designed an efficient and convenient scheduling publishing function, making content going online more strategic and automated.### Precisely control the timing of content going live Want to take advantage of the scheduling publishing feature of Anqi CMS, the process is actually very intuitive

2025-11-08

Does the background template editing function support real-time preview of content display effects?

AnQi CMS is favored by many operators for its efficient and flexible features in the field of website content management.When we talk about the visual presentation and user experience of a website, the customization capabilities of the template are undoubtedly the core.Among them, the real-time preview of the background template editing function and the display effect of the content is a focus for many users. ### The template editing capability of AnQi CMS: powerful and flexible AnQi CMS provides users with powerful and flexible backend template editing functions.The system uses a template engine syntax similar to Django, which is understandable for users familiar with front-end development or template languages

2025-11-08

How can I customize a template for a specific category or page to control the display style?

When operating a website, we often encounter situations where different types of content, even articles in the same category or different "About Us" pages on the same website, hope to have a unique display style to better attract readers and convey information.AnQiCMS (AnQiCMS) is well aware of this need and therefore provides a very flexible template customization mechanism, allowing us to easily tailor the display style for specific categories or pages.The Anqi CMS template system is based on the Django template engine syntax in Go language, which means that as long as you have a basic understanding of front-end development

2025-11-08

How to configure different content display templates for mobile and PC separately?

In website operation, providing a good browsing experience for different devices is crucial.AnQi CMS knows this, it provides a flexible template mechanism, allowing you to easily configure different content display templates for mobile and PC terminals, thereby meeting user needs and improving website performance.Below, let's take a detailed look at how to achieve this goal in Anqi CMS.### Understanding AnQi CMS Template Mode AnQi CMS provides three main website modes to meet the needs of content display on mobile and PC platforms in different scenarios: 1.

2025-11-08

What file extension should AnQiCMS template files use to ensure correct display?

When using AnQiCMS for website construction and content management, ensuring that the template files are displayed correctly is the foundation for the normal operation of the website.This is where, the naming convention of template files, especially the file extension, plays a crucial role. The template files of Anqi CMS have a clear and unified file extension requirement, which is to use **.html** as the file extension of the template files.These files are usually organized in the `/template` folder under the root directory of the website.Choose `.html`

2025-11-08