How to display the TDK (title, description, keywords) information of the website in AnQiCMS template?

Calendar 👁️ 54

AnQiCMS as a highly SEO-optimized content management system provides strong support for the search engine performance of website content.Among them, TDK (Title, Description, Keywords, that is, title, description, keywords) is a core element of SEO optimization. Properly displaying this information in the website template is crucial for improving the visibility of the website in search engines.This article will introduce how to effectively display these TDK information in the AnQiCMS template.

The importance of TDK information and its placement

In website development and content operation, TDK information is the important metadata that directly conveys the page topic, content summary, and core keywords to search engines. They are usually placed in the HTML page's<head>The tag has a direct impact on the ranking and click-through rate of the website.

In AnQiCMS, the TDK information setting is very flexible, covering global, category, single page, article, and tag levels and more:

  1. Global TDK Settings (Home TDK)This is the TDK at the website level, mainly used for the homepage.You can configure it in the "Background Settings" of AnQiCMS -> "Home TDK Settings", including the home title, keywords, and description.
  2. Content Level TDK Settings:
    • Article/Product Details PageWhen publishing or editing articles/products, you can find the 'SEO Title', 'Document Keywords', and 'Document Description' fields in the 'Add Document' or 'Edit Document' interface.In which, the 'Document Summary' is automatically extracted as a description with the first 150 characters of the content if not set.
    • Category PageIn the document category management, when editing a category, you can set the 'SEO title', 'keywords', and 'category description.' The 'category description' will also serve as the description information.
    • single pageIn the "Page Management" section, when editing a single page, you can set "SEO Title", "Keywords", and "Single Page Description".
    • Tab pageIn the 'Document Tag' management, when editing tags, you can set 'SEO Title', 'Tag Keywords', and 'Tag Description'.

This multi-level setting ensures that each page can have the most accurate and relevant TDK information, thereby improving SEO effectiveness.

Display TDK information in AnQiCMS template

AnQiCMS template system is based on syntax similar to Django, using double curly braces{{变量}}To output variables, use single curly braces and percent signs{% 标签 %}To call the function tag. There are mainly two ways to display TDK information: using the universaltdktag or directly accessing the page object properties.

1. It is recommended to use the universaltdkTag

AnQiCMS provides a very convenient and powerfultdkThe universal tag, it can automatically obtain and display the most suitable TDK information according to the type of the current page (home page, category page, detail page, etc).This greatly simplifies the template code, avoiding complex conditional judgments.

This tag is usually used in the HTML page<head>part. The following are its main uses:

  • Page title (<title>Label):

    <title>{% tdk with name="Title" siteName=true sep=" - " %}</title>
    

    here,name="Title"means to get the page title.siteName=trueIt will append the website name to the title, for example, “Page Title - Website Name”. This is very useful for brand exposure.sep=" - "Can customize the separator between the title and the website name, the default is-.showParent=trueCan be used on category pages, displaying the title of the parent category.

  • Page keywords (<meta name="keywords">Label):

    <meta name="keywords" content="{% tdk with name="Keywords" %}">
    

    name="Keywords"Will get the keywords of the current page.

  • Page description (<meta name="description">Label):

    <meta name="description" content="{% tdk with name="Description" %}">
    

    name="Description"The description of the current page will be obtained. It should be noted that when the page description may contain HTML tags (such as extracted from the summary), in order to avoid page rendering errors, it is usually necessary to cooperate withsafeThe filter is used:{% tdk with name="Description" %}{{description|safe}}ButtdkTags usually automatically handle this kind of escaping, so they can be used directly.

  • The standard link of the page (<link rel="canonical">Label): Standard links are very important for avoiding duplicate content and integrating page weight.

    {%- tdk canonical with name="CanonicalUrl" %}
    {%- if canonical %}
    <link rel="canonical" href="{{canonical}}" />
    {%- endif %}
    

    A conditional judgment was used, only output when the standard link exists to avoid empty outputcanonical.

A complete example(base.htmlOr the corresponding template's<head>the area):

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    {# 显示页面标题,并附加网站名称 #}
    <title>{% tdk with name="Title" siteName=true sep=" - " %}</title>
    {# 显示页面关键词 #}
    <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 %}
    {# 其他SEO元标签,如多语言hreflang #}
    {%- languages websites %}
    {%- for item in websites %}
    <link rel="alternate" href="{{item.Link}}" hreflang="{{item.Language}}">
    {%- endfor %}
    {%- endlanguages %}
    {# 可以在这里引入CSS文件 #}
    <link href="{% system with name="TemplateUrl" %}/css/style.css" rel="stylesheet">
</head>
<body>
    {# 网站内容 #}
</body>
</html>

UsetdkThe benefit of tags is that they intelligently select and output the most accurate TDK information according to the priority set in the AnQiCMS backend (Content detail page TDK > Category / Single page / Tag page TDK > Global TDK), without the need for you to manually write complex logic in the template.

2. Directly access object properties on a specific content page

In the article detail page, category page, single page, or tag page, etc., you can directly access the corresponding data object of the current page (such asarchive/category/page/tagThe TDK-related attributes. This method is suitable when you need to control or combine TDK information more finely, or whentdkthe tag does not meet specific requirements.

  • Article/Product Details Page: In the article (archive) or product

Related articles

How to set and display the navigation menu of the AnQiCMS website, does it support multi-level structure?

The website navigation is an important guide for users when visiting the website, a clear and easy-to-use navigation menu can greatly enhance the user experience.AnQiCMS offers very flexible and powerful functions in terms of website navigation settings and display, allowing us to easily manage and implement multi-level menu structures to meet the needs of various website layouts.In the AnQiCMS backend, all settings related to website navigation are concentrated in the "Navigation Settings" module.Enter this page, you will first see a "navigation category management" area.This feature is very useful

2025-11-08

How to make AnQiCMS automatically publish content at a specific time and display it?

In website content operation, maintaining a regular update and release rhythm is the key to attracting and retaining users.However, manually releasing content at specific time points is not only time-consuming but also prone to limitations imposed by human factors.AnQiCMS provides a very practical feature that can help you easily achieve scheduled content release and automatic display, making your website operation more efficient and automated.

2025-11-08

How to customize the content model in AnQiCMS to achieve diversified content display?

In website operation, the diversity of content is the key to attracting users, enhancing experience, and optimizing search engine rankings.AnQiCMS provides a highly flexible mechanism that allows users to break free from the constraints of traditional content management systems (CMS) such as 'articles', 'products', and other fixed templates. By customizing content models, it can achieve truly diverse content display.Why do we need a custom content model?

2025-11-08

How to batch replace keywords or links on AnQiCMS website to quickly update displayed content?

In website content operation, timely update and maintenance of content is crucial.Whether it is the unified adjustment of brand keywords or the link failure caused by external changes, manually modifying the content of the entire station one by one is undoubtedly a time-consuming and labor-intensive project.幸运的是,AnQiCMS provides an efficient and powerful feature that can help us easily cope with such challenges: full-site content replacement.This feature allows us to batch update keywords or links on the website, thus quickly and accurately maintaining the unity and timeliness of the website content.To use this convenient feature, we first need to log in

2025-11-08

How to display the friend link list in AnQiCMS?

In AnQiCMS, managing and displaying friendship links is very important for improving the website's search engine optimization (SEO) performance, increasing the number of external links, and promoting traffic interflow between websites.AnQiCMS as a fully functional content management system provides an intuitive backend operation and flexible template tags, allowing you to easily display a list of friend links on your website. ### One, manage friend links in AnQiCMS background Firstly, you need to add and manage friend links in the AnQiCMS background.

2025-11-08

How to use AnQiCMS filters to format and truncate output text content?

In the AnQiCMS content management system, the presentation effect of content often determines the user experience and the efficiency of information delivery.To meet the diverse content display needs, AnQiCMS provides a powerful and flexible template filter function.These filters can help us with fine-grained processing of the original text when displaying content, whether it's adjusting text style, optimizing display length, or performing data conversion, it can be easily achieved.

2025-11-08

How does AnQiCMS ensure the display quality of image resources and perform automatic compression and WebP conversion?

In the era where content is king, the image resources on the website play a crucial role.They not only directly affect the beauty of the page, but are also key factors in determining the loading speed and user experience of the website.For operators, how to ensure the display quality of images while also taking into account the performance and storage costs of the website is undoubtedly a question worthy of reflection.AnQiCMS (AnQiCMS) is well-versed in this, providing a comprehensive image resource management and optimization strategy, aimed at helping users easily master this challenge.The foundation for ensuring the quality of image display

2025-11-08

How to integrate and display Markdown, mathematical formulas, and flowcharts correctly on the AnQiCMS page?

In AnQiCMS, adding Markdown, mathematical formulas, and flowcharts to content greatly enhances its expressiveness and readability, especially for technical documents, educational materials, or data analysis reports.AnQiCMS as an efficient content management system, provides flexible mechanisms to support these modern content display needs. To implement the correct display of Markdown, mathematical formulas, and flowcharts on the AnQiCMS page, it mainly involves enabling backend settings and the necessary introduction of frontend templates.Here are the detailed steps and some practical suggestions

2025-11-08