How to set an independent display template and TDK for a specific Tag label in Anqi CMS?

Calendar 👁️ 63

AnQi CMS provides a powerful and flexible content management system, in which the Tag label is not only an important tool for content classification, but also a key factor for fine-grained SEO optimization and improving user experience.Many operators may want to display unique visual styles for different Tag label pages, or configure exclusive search engine optimization information (TDK) to achieve more accurate marketing goals.Next, we will delve into how to achieve this goal in Anqi CMS.

Understanding Tag label management in Anqi CMS

In Anqi CMS, Tag labels are not just accessories of article content, they have independent management interfaces and configurable properties. Through the background "Content Management" -> "Document Tags" module, you can set up each tag in detail, including:

  • Tag name:The tag name displayed to the user on the front end.
  • Custom URL:Generate a friendly URL path for the tag page, which is crucial for SEO.
  • SEO Title:Page titles designed specifically for search engines, usually more descriptive than tag names.
  • Tag keywords:The core keywords of the tag page, helping search engines understand the page theme.
  • Tag description:Tag page Meta Description, briefly summarize the page content, attract users to click.

These backend settings are the foundation for implementing personalized Tag page TDK, ensuring that each tag page can have independent SEO configuration.

Set an independent display template for a specific Tag tag

The AnQi CMS template system is highly flexible, allowing you to specify independent display templates for different types of content (such as articles, categories, single pages). For Tag tags, AnQi CMS provides default templates.tag/index.html(Tag homepage) andtag/list.html(Tag document list page) serves as a general template. However, to design a unique display layout for a specific Tag label, you need to skillfully use the conditional judgment and local template introduction features of the template.

Due to the lack of a field to directly specify a template in the tag management interface of AnQi CMS, like that provided for categories or single pages, the strategy to implement the 'Independent Display Template' is totag/list.htmlThis universal template internally uses code logic to determine which Tag is being accessed and then introduces different local template files based on the judgment result.

The specific implementation approach is as follows:

  1. Prepare the local template file:In your theme template directory (for example/template/your_theme/), you can create a subdirectory specifically for storing custom Tag label templates, such aspartial/tag_templates/. Here, you can create a template file for a specific Tag, such astag-brandA.html/tag-event.html, and one as a backuptag-default-list.html. These local templates will contain the unique layout and style you want.

  2. Intag/list.htmlPerforming conditional judgment: tag/list.htmlIs the entry point of all Tag document list pages. In this file, you can use:tagDetailTag to get the detailed information of the current Tag, and then according to itsId/TitleorLinkPerform conditional judgment on properties and dynamically import pre-prepared local templates.

    For example, yourtag/list.htmlThe file can be written like this:

    {% tagDetail currentTag %} {# 获取当前Tag的详细信息 #}
    
    {% if currentTag.Title == "品牌A" %}
        {% include "partial/tag_templates/tag-brandA.html" %}
    {% elif currentTag.Id == 123 %} {# 假设TagID为123是"活动专题" #}
        {% include "partial/tag_templates/tag-special-event.html" %}
    {% else %}
        {# 默认的Tag列表显示逻辑,或者引入一个通用的局部模板 #}
        {% include "partial/tag_templates/tag-default-list.html" %}
    {% endif %}
    

    In this way, when the user visits the page of the "BrandA" tag, the system will loadtag-brandA.htmlthe defined layout; when visiting the "Event Special" tag, it will loadtag-special-event.htmlAnd other tags not specified will revert totag-default-list.html.

  3. Call tag data in local templates:Intag-brandA.html/tag-special-event.htmlIn the local templates, you can continue to usetagDataListTag to retrieve the document list under the specified Tag and display it according to your design.

Fine management of Tag tags' TDK.

For Tag tag's TDK, Anqi CMS provides a very convenient management and calling method.When you set the "SEO title", "tag keywords", and "tag description" for a certain Tag in the "Document Tags" section of the background, when calling the TDK information in the template, the system will intelligently extract the corresponding Tag TDK based on the current page context.

This means you do not need to write complex TDK extraction logic for each Tag tag page. Just use the universal header template of the website (usuallybase.htmlorpartial/header.html) provided by Anqi CMS.tdkLabel it:

<!DOCTYPE html>
<html lang="{% system with name='Language' %}">
<head>
    <meta charset="UTF-8">
    <title>{% tdk with name="Title" siteName=true %}</title> {# siteName=true 会自动附加网站名称 #}
    <meta name="keywords" content="{% tdk with name="Keywords" %}">
    <meta name="description" content="{% tdk with name="Description" %}">
    {%- tdk canonical with name="CanonicalUrl" %}
    {%- if canonical %}
    <link rel="canonical" href="{{canonical}}" />
    {%- endif %}
    {# 其他CSS、JS等资源引入 #}
</head>
<body>
    {# 页面内容 #}
</body>
</html>

When the user visits any Tag page,<title>/<meta name="keywords">and<meta name="description">The tag will automatically fill in the SEO title, tag keywords, and tag description set in the background for the current Tag.This mechanism greatly simplifies the management of TDK, ensuring the accuracy and independence of SEO information.

Summary

By the above strategy, you can flexibly customize independent display templates and TDK information for specific Tag tags in Anqi CMS. This not only

Related articles

How does AnQi CMS manage and display website image resources, including categories and details?

In website operation, image resources play a crucial role, not only directly affecting user experience, but also being a key factor in the attractiveness of website content and search engine optimization (SEO).A high-efficient CMS system should provide a complete set of image management and display mechanisms.AnQiCMS (AnQiCMS) considers this aspect quite thoroughly, it provides a series of features to help users easily manage and optimize the image resources of their websites, whether it is from classification and archiving, intelligent processing to multi-scene display, it strives to be simple and efficient.

2025-11-08

How to retrieve and display detailed information of different user groups (such as VIP levels) in Anqi CMS template?

In Anqi CMS, implementing personalized information display based on the user's group membership, such as their VIP level, is a key step to improving website user experience and content monetization capabilities.AnQi CMS provides a powerful and flexible user group management function, and we can easily implement this requirement in the front-end template through simple template tag combinations. ### Understanding Anqi CMS User Groups and VIP System One of the core strengths of Anqi CMS is its user group management and VIP system.

2025-11-08

How to implement a custom prompt display for a website in off-site status in AnQi CMS?

In website operations, for reasons such as maintenance, upgrade, or emergency handling, it is sometimes necessary to temporarily set the website to be offline.A good content management system (CMS) not only provides this basic function, but should also allow you to display custom prompts to visitors during the site shutdown to maintain a good user experience and convey necessary notifications.AnqiCMS (AnqiCMS) provides such a flexible and practical mechanism.Why do you need to shut down and display a custom prompt?The website shutdown does not mean a simple interruption of service, but is an important operational strategy

2025-11-08

How to truncate, convert case or concatenate strings in AnQi CMS templates?

In the daily use of the Anqi CMS template, flexibly handling text content is the key to improving the display and user experience of the website.Whether it is the concise title of an article, the formatting of user comments, or the combination of product descriptions, mastering the skills of string truncation, case conversion, and concatenation can make your content more expressive.The Anqi CMS is based on the Django template engine syntax, providing a series of powerful and easy-to-use filters (Filters) that make these operations simple and intuitive.

2025-11-08

How to quickly fill and display website content using the 'Content Collection and Bulk Import' function of AnQi CMS?

Today, as digital content becomes increasingly a core asset of enterprises, how to efficiently and quickly fill and update website content is an important issue facing every website operator.Manual data entry often fails to keep up with the update of massive information, it takes time and effort and is prone to errors.AnQiCMS (AnQiCMS) understands this pain point, its built-in 'Content Collection and Batch Import' feature is designed to solve this challenge, as if it is providing an automated production line for your website content operations, helping your website content to recover quickly and accurately.

2025-11-08

How can I display long text content automatically with line breaks at specified lengths in the Anqi CMS template?

In website operation, we often encounter situations where we need to display long text content within limited layout space.If not processed, these texts may cause page layout to be disordered, affecting the user's reading experience.AnQiCMS (AnQiCMS) offers flexible template functions and rich filters to help us easily solve this problem.This article will discuss in detail how to display long text content with automatic line breaks in the Anqi CMS template and introduce the related content truncation processing method.

2025-11-08

How to format numbers to display in Anqi CMS template (such as floating-point precision)?

In website content management, we often need to display various numerical information, such as product prices, discount percentages, and statistical data, etc.These numbers may sometimes have complex decimal places, and if displayed directly, they may not look beautiful or be difficult to read.AnQiCMS (AnQiCMS) provides a powerful and flexible template engine, which adopts the syntax features of Django templates. Through the built-in filter (filter) function, it can conveniently format numbers, especially the precision control of floating-point numbers.

2025-11-08

How does the custom static rule of AnQi CMS affect the display of the category list URL?

In AnQiCMS, the URL structure of the website is crucial for search engine optimization (SEO) and user experience.A clear and meaningful URL can not only help search engines better understand the content of the page, but also make it easier for users to remember and share the link.Aqii CMS provides powerful pseudo-static functions, especially its custom mode, which allows users to finely control the display method of the URL for category list pages.

2025-11-08