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