As a senior person deeply involved in the operation of AnQiCMS (AnQiCMS) website, I am well aware of the importance of TDK (Title, Description, Keywords) for website search engine optimization (SEO), especially for the 'front door' of the website - the homepage. The precise setting and effective calling of its TDK are of great importance. AnQiCMS provides a powerful and flexible template tag system, which{% tdk %}标签便是管理页面元信息的利器。

这篇文章将详细阐述如何利用AnQiCMS的{% tdk %}Label, precisely obtain and display the Keywords (keywords) and Description (description information) on the homepage in the template.


Precisely obtain the home page Keywords and Description:{% tdk %}Practical application of tags

In website operation, the home page TDK is a key element that conveys the core information of the website to search engines and attracts target users to click. Anqi CMS is well-versed in this.{% tdk %}The universal tag was born for this.It can intelligently recognize the context of the current page and automatically extract the corresponding TDK information, greatly simplifying the work of template developers.For the homepage, this means that the system can directly retrieve the preset content in the "Homepage TDK Settings" in the background without any additional parameter configuration.

Call Home Page Keywords (Keywords)

The home page keywords are the core vocabulary that inform search engines of the main content covered by the website. In the Anqi CMS template, to obtain the home page Keywords, we mainly use{% tdk %}label combined withname="Keywords"parameters.

Specifically, you can use the following code structure in the homepage template file:<head>In the area, use the following code structure to output the homepage keywords:

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

This code's purpose is: when the page loads, the template engine of Anqi CMS will parse{% tdk with name="Keywords" %}This part of the label. Since the current page is the website's homepage, the system will automatically go to the "Homepage TDK Settings" on the backend to find the keywords you have configured for the homepage and replace their values.contentProperty in, finally rendered in the browser<meta name="keywords" content="您的首页关键词">Such HTML code. This ensures that search engines can accurately identify and understand the keyword information of your website's home page.

Call Home Page Description (Description)

The homepage description is a concise summary of the content on the website's homepage, which usually appears in the abstract part of the search engine results page and directly affects the user's willingness to click. Similar to keywords, obtaining the homepage description also depends on{% tdk %}Label, but need tonameparameter settingsDescription.

To display the home page description in the template, you can in the home page template file<head>Use the following code in the region

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

This template code's execution logic is the same as when retrieving keywords: The template engine of Anqi CMS will identify and parse{% tdk with name="Description" %}标签,自动从后台“首页TDK设置”中提取您为首页定义的描述内容,并将其填充到English<meta name="description" content="您的首页描述">The corresponding position. A clear and attractive homepage description is crucial for improving click-through rate and user experience.

Comprehensive Application: Build a complete homepage TDK structure

In practical web development, the Title (title), Keywords, and Description of the homepage are usually present and closely collaborative. The following is a complete homepage<head>Area TDK code example, showing how to combine them organically:

<!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" %}">
    <!-- 其他Meta信息和CSS链接 -->
</head>
<body>
    <!-- 网站内容 -->
</body>
</html>

In this example,{% tdk with name="Title" siteName=true sep=" - " %}The tag not only gets the home page title, but alsositeName=trueAutomatically added the website name as a suffix, and usessep=" - "Specified the delimiter.KeywordsandDescriptionAs described above, directly obtain and output the corresponding content.

Important hints for operators.

As a website operator, you should always keep in mind,{% tdk %}The power of the label lies in its direct mapping to the TDK settings of the security CMS backend.Therefore, it is crucial to fill in high-quality, relevant, and SEO-compliant titles, keywords, and descriptions in the "Home Page TDK Settings" in the background.contentThe property will be empty, unable to play its SEO role.

Through this method, the Aanqi CMS of{% tdk %}The label provides a centralized, efficient, and easy-to-manage solution, allowing you to easily configure and call key SEO meta information for the website homepage, thereby optimizing search engine performance and attracting more potential users.


Common Questions and Answers (FAQ)

1. I have already configured the keywords and descriptions in the "Home Page TDK Settings" on the backend, why isn't the home page displaying?Firstly, please check if your homepage template file has used{% tdk with name="Keywords" %}and{% tdk with name="Description" %}tags correctly, and make sure they are located in<head>in the area.Next, check the browser cache, sometimes you need to clear the cache for the front-end updates to take effect.If the issue still exists, please confirm that the template file is the one currently being used by the website, and that there is no other custom code overriding these meta tags.

2.{% tdk %}Can tags be used on other pages besides getting the homepage's TDK?Of course you can.{% tdk %}标签是一个“万能”标签,它会根据当前页面的类型(例如文章详情页、分类列表页、单页面等)自动获取对应的TDK信息。On these pages, it will try to extract the SEO title, keywords, and description of the article or category itself.<head>The region can use this set of tags without needing to write different TDK acquisition logic for different page types, which greatly improves the reusability of the template.

3. If my website does not set the home page TDK,{% tdk %}what will the tag output?If the corresponding field in the background "Home Page TDK Setting" is left blank,{% tdk %}The label will be empty when getting these fields.contentFor example, if the home page keywords are not set,{% tdk with name="Keywords" %}an emptycontentproperty will be output, i.e.<meta name="keywords" content="">This is not typically an ideal SEO practice; it is recommended to provide complete TDK information for the homepage.