As an experienced website operations expert, I have accumulated rich experience in the practical application of content management systems, especially in AnQiCMS (AnQiCMS).I am fully aware that efficient content operation is inseparable from in-depth exploration and flexible application of the system functions.{% tagList %}Explore how to cleverly utilize it to obtain and display a specified number of document tag lists, thereby optimizing the website's content layout and user experience.

Tags, the 'DNA' of website content.

In modern content operation, tags (Tags) play a crucial role.They are like the 'DNA' of the content, able to describe the core themes of articles or products from multiple dimensions, helping users quickly find content of interest, and also providing richer semantic information for search engines, thereby enhancing the SEO performance of the website and the quality of internal links.A meticulously designed tag system that not only makes the website structure clearer but also effectively extends the user's stay time on the site, guiding them to discover more relevant value content.

AnQiCMS provides an intuitive and powerful backend support for tag management, allowing you to easily add, edit, and manage tags for documents (for details, please refer tohelp-content-tag.md)and these meticulously managed tags need to be presented on the website frontend, which brings us to today's main character—{% tagList %}Label.

use cleverly{% tagList %}:Get a list of tags with a specified number

{% tagList %}It is a core tag used to get the document tag list in AnQiCMS template engine. Its basic syntax structure is simple and clear, usually starting with{% tagList 变量名 %}Start, with{% endtagList %}and ending withforLoop through label data.

For example, the most basic way to call a label list is:

{% tagList tags %}
    {% for item in tags %}
        <a href="{{item.Link}}">{{item.Title}}</a>
    {% endfor %}
{% endtagList %}

This code will retrieve all available tags and display their names and links one by one.However, in actual operation, we often do not need to display all tags at once, but rather hope to selectively display a specified number of tags based on page layout, content strategy, or user needs.limitThe parameters become particularly important.

Precise control of quantity:limitThe magic of parameters

limitThe parameter allows you to precisely specify the number of tags you want to retrieve. For example, if you only want to display the latest 5 popular tags in the sidebar, you can use it like this:

{% tagList tags with limit="5" %}
    <div class="sidebar-tags">
        <h3>热门标签</h3>
        <ul>
            {% for item in tags %}
                <li><a href="{{item.Link}}" title="查看所有关于{{item.Title}}的文档">{{item.Title}}</a></li>
            {% endfor %}
        </ul>
    </div>
{% endtagList %}

By usinglimitset"5"The system will only return the first 5 tags. It should be noted that,limitThe range of parameter values is usually from 1 to 100, and you can adjust this number according to your actual needs.

Furthermore,limitThe parameter also supportsoffsetOffset mode, which allows you to start retrieving a specified number of tags from a specified position in the tag list. For example, if you want to skip the first 2 tags and display the next 8 tags, you can set it up like this:

{% tagList tags with limit="2,8" %} {# 从第3个标签开始(跳过前2个),获取8个标签 #}
    <div class="advanced-tags">
        <h3>进阶标签展示</h3>
        <p>(跳过前两个,展示接下来8个)</p>
        <ul>
            {% for item in tags %}
                <li><a href="{{item.Link}}"># {{item.Title}}</a></li>
            {% endfor %}
        </ul>
    </div>
{% endtagList %}

Here are the"2,8"This JSON array contains a translation of the original content: "Skipping the first 2 tags in the list and then getting the next 8 tags. This flexibility is very useful when building complex tag clouds or multi-block tag displays."

More practical parameter expansion

Exceptlimitparameters,{% tagList %}Also provides some other parameters to make label acquisition more accurate and context-related:

  • itemIdIf you want to get the tags of a specific document, you can use it on the document detail pageitemId=archive.Id(Assumingarchiveis the current document object). If set toitemId="0"This indicates that all tags of the site are retrieved, not bound to the current document.
    
    {% archiveDetail currentArchive with name="Id" %} {# 假设这里已经获取了当前文档ID #}
    {% tagList tags with itemId=currentArchive limit="5" %}
        <h4>当前文档的相关标签:</h4>
        {% for item in tags %}
            <a href="{{item.Link}}">{{item.Title}}</a>
        {% endfor %}
    {% endtagList %}
    
  • categoryId: When you want to display tags contained in documents under a specific category, you can use this parameter. For example,categoryId="1,2"Retrieve the tags associated with documents having category ID 1 or 2.
  • letter: Used to filter tags that start with a specific letter, for exampleletter="A"It will only display tags that start with the letter A, which is very useful when building an A-Z tag index.
  • siteId: For users who use the AnQiCMS multi-site management feature,siteIdCan specify from which site to retrieve label data, achieving cross-site content calling.

Content operation strategy and **practice

Mastered{% tagList %}usage, the next is how to maximize its value in operation:

  1. Sidebar/Footer Tag Cloud:UtilizelimitDisplay the most popular or latest few tags on the website, attracting users to click and increasing the weight of internal links.
  2. Tags related to the article detail page:CombineitemIdParameters, displayed at the bottom of each article, showing closely related tags to guide users to read more content on the same topic.
  3. Tag classification on special topic pages:For specific categories or special topics,categoryIdDisplay related tags for parameter filtering and strengthen the aggregation of special topic content.
  4. Avoid "tag stacking":Tags should be precise and relevant, not just a simple list of keywords. Too many irrelevant tags can dilute the weight of keywords, affecting user experience and SEO performance.
  5. Regular maintenance:Operational personnel should regularly check and clean up unused, duplicate, or outdated tags to ensure the vitality and effectiveness of the tag system.

Summary

{% tagList %}Tags are an indispensable tool in the AnQiCMS content operation toolbox. By flexibly utilizing itslimit/itemIdParameters such as these allow you to precisely control the number and range of tags displayed on the website's front end, which not only optimizes the visual layout of the page but also effectively enhances the efficiency of users' content discovery and the overall SEO performance of the website.I hope this article can help you better understand and utilize this feature, making your website content more attractive!


Common Questions (FAQ)

Q1:limitWhat is the range of parameter values? If I want to display all tags? A1: limitThe value range for the parameter is usually 1 to 100. You can omit it if you want to display all tags.limitthe parameter, or set a sufficiently large number (such aslimit="100"),but AnQiCMS usually defaults to fetching all, unless explicitly specified the pagination type.

Q2: How to{% tagList %}only display the tags of the current document, not the tags of the entire site? A2:In the document detail page, you can useitemId=archive.Idparameters (assuming the current document data has been{% archiveDetail archive %}accessed with tags likearchivevariables). This way,{% tagList %}only the tags associated with the current document will be retrieved and displayed.

**Q3: Besides the tag name and link, what else can I