As an experienced CMS website operation person in an enterprise security company, I know the key role of every page in search engine optimization, especially the SEO title and description.They are not only the first line of defense to attract users to click, but also an important signal to convey the core content of the page to search engines.The Anqi CMS deeply understands this, providing us with powerful and flexible template tags, allowing us to accurately control each page's SEO elements.

SEO settings for single pages in Anqi CMS

In the AnQi CMS backend, the SEO title and description of a single page have a clear setting location, which allows operation personnel to carry out refined configuration according to the specific content and optimization objectives of the page.When entering the "Page Resources" under the "Page Management" feature, editing or adding a single page, you will find the fields of "SEO Title" and "Single Page Introduction".

Amongst them, the "SEO Title<meta name="description">Tag content, it is a brief summary of the page content, designed to attract users to click. These backend settings are the direct source of SEO information for the front-end template tags.

Get the core template tag for a single-page SEO title:tdk

Anqi CMS provides a 'Universal TDK tag' -tdkA tag that can intelligently obtain and output the corresponding TDK (Title, Description, Keywords) information based on the context of the current page. For a single page,tdkThe tag will prioritize reading the "SEO title" and "page summary" set for this single page in the background.

To obtain the SEO title of a single page, we can use the following tags in the template:

<title>{% tdk with name="Title" %}</title>

This tag dynamically outputs the current single page's content in the "SEO Title" field in the background. If we need to attach the website name to the end of the SEO title to enhance brand recognition, we can use it like this:

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

At this time, the output title will be "Single Page SEO Title - Website Name". We can also usesepcustom separator parameters, for examplesep="_".

Get the core template tag for single-page SEO description:tdk

Similarly, usetdkLabel, we can easily obtain the SEO description of a single page. It will read the content of the background "Single Page Introduction" field and output it to the page.<meta name="description">tags:

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

Auxiliary template label:pageDetail

AlthoughtdkThe tag is the preferred method to obtain the SEO title and description for a single page, as it directly corresponds to the SEO configuration fields in the backend. However, in some cases, if the backend has not separately set the "SEO Title" and "Single Page Summary", or if we want to directly obtain the main title and content summary of the single page (instead of the specific SEO fields),pageDetailLabels can also be useful.

pageDetailLabels are mainly used to obtain detailed information about a single page, including its page name (Title) and a brief introduction (Description)

To get the main title of a single page:

<div>页面主要标题:{% pageDetail with name="Title" %}</div>

Get the summary content of a single page:

<div>页面内容简介:{% pageDetail with name="Description" %}</div>

It should be noted that,pageDetailThe tag retrieves the original title and summary of a single page, whiletdkThe tag is more focused on the specific fields optimized for search engines on the backend.In cases where both the SEO title and the main title are set, there may be differences.tdkThe tag ensures that the search engine retrieves the SEO information we have carefully optimized.

Actual application example

Apply these template tags to the HTML header of a single page to build a comprehensive SEO structure. The following is a typical single page<head>code block example:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    {# 使用tdk标签获取单页面的SEO标题,并附加网站名称 #}
    <title>{% tdk with name="Title" siteName=true %}</title>

    {# 使用tdk标签获取单页面的SEO关键词(如果后台有设置) #}
    <meta name="keywords" content="{% tdk with name="Keywords" %}">

    {# 使用tdk标签获取单页面的SEO描述 #}
    <meta name="description" content="{% tdk with name="Description" %}">

    {# 获取页面的规范链接,通常用于防止重复内容问题 #}
    {%- tdk canonical with name="CanonicalUrl" %}
    {%- if canonical %}
    <link rel="canonical" href="{{canonical}}" />
    {%- endif %}

    {# 引入CSS文件等其他头部元素 #}
    <link rel="stylesheet" href="{% system with name='TemplateUrl' %}/css/style.css">
</head>
<body>
    {# 页面内容 #}
</body>
</html>

This code ensures that each single page can dynamically have exclusive and optimized SEO titles and descriptions, greatly facilitating the SEO management of the website.

Frequently Asked Questions

Q:tdkCan the tag be used on any type of page?A: Yes,tdkThe tag is a "universal TDK tag" designed to intelligently retrieve and output the SEO title, keywords, and description of the current page on any page type (such as the homepage, article detail page, category list page, single page, etc.)It will automatically identify and read the corresponding SEO configuration from the background according to the context of the page.

Q: If I have not set the "SEO title" and "page summary" for the single page,tdkwhat will the tags return?A: If the backend has not set a special 'SEO title' for the single page,tdkThe label usually falls back to using the main title of a single page (i.e., the 'Page Name' field).Similarly, if the 'single-page overview' is empty, it may attempt to extract the first N characters of the page content as a description, or return an empty value, the specific behavior may depend on the default template logic and system configuration.In order to enhance SEO effects, it is strongly recommended to manually set SEO titles and descriptions for each important single page.

Q:pageDetailandtdkWhat is the difference between the title and description obtained?A:pageDetailThe tag is mainly used to obtain the core content attributes of a single page, such as its main title (usually used for internal display on the page, such as H1 tag) and main content description. AndtdkThe tag focuses on obtaining specific fields for search engine optimization, namely the content entered in the backend "SEO title" and "single-page introduction".In many cases, especially when operators want to display different titles/descriptions to search engines and users, the content obtained from these two tags may be different.tdkTag to set the page<title>and<meta name="description">To ensure the optimization effect of search engine.