How to dynamically set the `title`, `keywords`, and `description` metadata of a page using the `tdk` tag?

Calendar 👁️ 77

In the practice of website operation and Search Engine Optimization (SEO), page metadata (meta data) plays a vital role. Among them, the page title (title), keywords (keywords) and descriptions (descriptionIt directly affects the display effect of the website in the search engine results page and the willingness of users to click. AnQiCMS (AnQiCMS) understands its importance and provides a powerful and flexibletdkTags, help us dynamically and efficiently manage these key metadata.

tdkThe core role of tags: intelligent adaptation of page metadata.

Of Security CMStdkTags are a universal and powerful tool that can automatically capture and output the corresponding title, keywords, and description based on the current page type and backend configuration. This means that no matter which page the user visits, whether it is the homepage of a website, a detailed page of an article, a category list page, or a single page,...tdkTags can intelligently present the metadata that best fits the content of the page, without the need to manually write complex logic for each page.

一般情况下,we would use the template file<head>area.tdkLabel to configure this information.

<head>
    <meta charset="UTF-8">
    <title>{% tdk with name="Title" %}</title>
    <meta name="keywords" content="{% tdk with name="Keywords" %}">
    <meta name="description" content="{% tdk with name="Description" %}">
    <!-- 其他页面元数据 -->
</head>

Next, we will learn in detail.tdkThe various functions of the label and its flexibility in practical applications.

Detailed analysistdkThe various functions of the label

tdkTag throughnameTo specify the specific metadata type to be retrieved, and provides additional parameters to finely control the output.

1. Dynamically set the page title (Title)

The page title is the most direct signal for search engines to understand the content of the page, and it is also the first information that users see in the search results.tdkTags provide great flexibility when setting page titles:

  • Basic usage:The simplest way is to directly output the title of the current page.
    
    <title>{% tdk with name="Title" %}</title>
    
    At this moment, it will automatically extract the title configured in the background according to the type of the current page (home page, article, category, etc.).
  • Attach website name:To maintain brand consistency, we usually want to add the website name after each page title. By settingsiteName=trueyou can achieve it.
    
    <title>{% tdk with name="Title" siteName=true %}</title>
    
    For example, if the page title is “AnQi CMS Tutorial”, and the website name is “AnQi CMS”, then the final displayed title may be “AnQi CMS Tutorial - AnQi CMS”.
  • Custom separator:By default, the website name and page title are separated by a hyphen-Separator. If you need to use a custom separator, you can usesepParameter.
    
    <title>{% tdk with name="Title" siteName=true sep=" | " %}</title>
    
    This title may be changed to "AnQi CMS Tutorial | AnQi CMS".
  • Display parent category title:In some deeply nested category pages or article detail pages, we may want the title to reflect the hierarchy of the parent categoryshowParent=trueThe parameter can help us achieve this.
    
    <title>{% tdk with name="Title" siteName=true showParent=true %}</title>
    
    For example, if an article belongs to the "SEO Optimization" category under the "Keyword Research" subcategory, the title may be displayed as "Article Title - Keyword Research - SEO Optimization - AnQi CMS".

2. Define the page keywords (Keywords)

The weight of keywords in modern SEO may not be as strong as before, but it is still a way to provide search engines with page topic information.The AnQi CMS allows separate keyword settings for the homepage, articles, categories, and single pages in the background.

  • Basic usage:Byname="Keywords"and output the keyword list corresponding to the current page.
    
    <meta name="keywords" content="{% tdk with name="Keywords" %}">
    
    These keywords are usually extracted from the "document keywords" or "category keywords" fields of various content types in the background.

3. Optimize page description (Description)

The page description is a brief summary of the page content, which is directly presented below the search result title and is the key copy to attract users to click.A captivating description can effectively improve click-through rate.

  • Basic usage:Usename="Description"Output the description of the current page.
    
    <meta name="description" content="{% tdk with name="Description" %}">
    
    The page description usually comes from the "document introduction", "category introduction", or "single page introduction" fields of various content types in the background.

4. Processing specification link (CanonicalUrl)

The canonical URL is used to inform search engines which is the preferred version of the page, to avoid SEO issues caused by duplicate content, especially in cases where multiple URLs point to the same content.

  • Basic usage:Byname="CanonicalUrl"Output the specification link of the current page.
    
    <link rel="canonical" href="{% tdk with name="CanonicalUrl" %}" />
    
  • Use safely:The standard link is not required or set on all pages. In the template, we should always first check if it exists before rendering to avoid outputting empty.hrefProperty.
    
    {%- tdk canonical with name="CanonicalUrl" %}
    {%- if canonical %}
    <link rel="canonical" href="{{canonical}}" />
    {%- endif %}
    

tdkThe label's performance across different page types

tdkThe strength of the label lies in its ability to automatically adapt to different page contexts:

  • Homepage of the website:Metadata comes from the "background settings" -> "Home TDK settings" where the title, keywords, and description are configured.
  • Article detail page:Metadata is preferred to be extracted from the "SEO title", "document keywords", and "document description" fields of the current article.If these fields are empty, the system may try to generate from the article title, content summary.
  • Category list page:Metadata is preferably extracted from the 'SEO Title', 'Keywords', and 'Category Description' fields of the current category.
  • Single page:Metadata is prioritized from the "SEO title", "keywords", and "single page introduction" fields of the current page.

This dynamic acquisition mechanism greatly reduces the workload of content operation personnel, while ensuring that each page's metadata is properly managed.

**Practice and Content Operation Strategy

Just understandtdkThe method of using tags is not enough, it needs to be combined with effective content operation strategies to maximize its value:

  1. Content is king, TDK is the cherry on top:No matter how metadata is optimized, high-quality, valuable page content is always the foundation for attracting users and search engines. TDK tags are just to help content be better discovered and understood.
  2. Keywords should be naturally integrated, avoid stacking:When writing page titles, descriptions, and keywords, it is important to strive for natural flow and avoid repetition of keywords (keyword stuffing), as this may be viewed as cheating by search engines.
  3. Describe something attractive, summarize the core of the page:The page description is the content summary that users see in search results, it should accurately summarize the page content, include a call to action or unique selling point, and attract users to click.
  4. Personalization and Differentiation:For different types of pages (home page, article, category), the TDK settings should be emphasized.For example, the home page TDK should focus on the brand and core business, and the article TDK should revolve around the article theme and long-tail keywords.
  5. Regular inspection and optimization:After the website goes live, it is not a one-time task. It should be monitored regularly through traffic statistics, search engine site master tools, etc., to adjust and optimize based on data feedback.

By flexibly using AnQi CMS'stdkLabels, combined with refined content operation strategies, we can significantly improve the search engine visibility of the website, attract more target users, and thus achieve better operational results.


Frequently Asked Questions (FAQ)

Q1: I set the page TDK information in the background, but the front-end page did not display. What could be the reason?A1: There could be several reasons:

*   **标签未正确放置或拼写错误:** 确保 `tdk` 标签被正确地放置在HTML的 `<head>` 区域,并且 `name` 属性(例如 `name="Title"`)没有拼写错误。
*   **后台数据未保存:** 检查您是否在安企CMS后台相应内容的TDK字段中输入了信息并成功保存。
*   **缓存问题:** 清理安企CMS的系统缓存

Related articles

How to display the contact information set in the website backend on the front page of AnQi CMS?

When using Anq CMS to build a website, displaying the contact information set in the background to the website front end is a key step to enhance user experience and establish trust.AnQi CMS provides a very intuitive and flexible way, even without a strong technical background, it can be easily realized. ### Configure the contact information of the website backend Firstly, you need to configure the contact information in the Anqi CMS backend management interface. Generally, you can find the 'Background Settings' in the left navigation bar, clicking on it will show the 'Contact Information Settings' option.

2025-11-09

How to use the `system` tag to retrieve and display the global information of a website, such as the website name, Logo, and filing number?

It is crucial to maintain the consistency of brand image and the accuracy of information in website operation.AnQi CMS is an efficient content management system that provides us with a convenient way to manage and display these core information.Today, let's delve into how to use the `system` tag of Anqi CMS to easily obtain and display global information on the website template, such as the website name, Logo, and filing number.

2025-11-09

How to format a timestamp into a readable date and time using the `stampToDate` tag in AnQi CMS?

In website operation, the display of time information is crucial. Whether it is the publication date of articles, the update time of products, or the submission time of comments, a clear and easy-to-read date and time format can greatly enhance the user experience.The original timestamp is machine-friendly, but it is cryptic to ordinary visitors.Fortunately, AnQiCMS (AnQiCMS) provides a very convenient template tag——`stampToDate`, which can easily format timestamps into the date and time we are familiar with.### `stampToDate` label

2025-11-09

How to implement diverse data layout and display with the `for` loop tag in AnQi CMS?

How to present information in a more rich and attractive way during website content operation is the key to improving user experience and site activity level.AnQiCMS (AnQiCMS) provides us with the tool to achieve this goal with its flexible content model and powerful template engine.Among them, the `for` loop iteration tag is the essential core tool for us to perform diverse formatting and display.Imagine your website is not just a static pile of articles, but can intelligently present lists of articles, product galleries, category navigation, user comments, and even custom parameters based on different scenarios

2025-11-09

How does Anqi CMS ensure that static rules (such as model naming patterns) are correctly generated and displayed in URLs?

In website operation, a clear and friendly URL address not only allows visitors to understand the page content at a glance but is also an indispensable part of search engine optimization (SEO).A well-structured URL can help search engines better understand the page topic, thereby improving the crawling efficiency and ranking of the website.Our CMS deeply understands this, providing a simple, easy-to-use, and highly flexible solution for generating and displaying static rules.

2025-11-09

How to implement the correct rendering and style display of Markdown content in AnQi CMS template?

Markdown is favored by content creators for its concise and efficient characteristics.In AnQi CMS, using Markdown not only allows for quick content creation but also enables simple configuration to perfectly display these contents on the frontend page, including rich styles, mathematical formulas, and even flowcharts.This article will introduce in detail how to make your Markdown content render correctly and have a beautiful style in the Anqi CMS template.Enable Markdown editor First

2025-11-09

How does AnQi CMS generate and display thumbnails of different sizes for image resources?

In website operation, the loading speed and display effect of images directly affect user experience and search engine optimization.Especially for content management systems with a large number of images, how to efficiently generate and display thumbnails of different sizes is a crucial function.AnQiCMS (AnQiCMS) provides a flexible and powerful solution in this regard, making it easy to manage and display image resources. ### Core Advantage: Intelligent Generation and Flexible Upload AnQiCMS does a very good job in handling image resources.It is the most reassuring feature

2025-11-09

How to process front-end displayed data twice through the `filter` filter, such as truncating characters or formatting?

In Anqi CMS, data is stored in its original form, but we know that the data presented on the front end needs to be carefully crafted to present in a **pose to the users. At this point, the 'filter' in the template engine has become an indispensable tool in our hands.It can process data twice, whether it is accurately截取 long text, unify date format, or cleverly handle HTML content, it can easily cope with it, making your website content both professional and attractive.### Understanding the core role of "filter" Imagine one

2025-11-09