How to obtain the SEO title and description of a single page through template tags?

Calendar 👁️ 67

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.

Related articles

How to use the lazy loading feature of images in single page content?

As an experienced AnQiCMS website operator, I know the importance of website performance for user experience and SEO.Lazy loading of images is an essential optimization method to improve website loading speed, especially on single-page content that contains a large number of images.AnQiCMS provides good support for lazy loading of images at the content rendering level, allowing us to implement this feature through simple template configuration combined with front-end technology. I will elaborate in detail on how to implement lazy loading of images in the single-page content of AnQiCMS.

2025-11-06

How to determine if a single page exists in the template and display its content?

As an experienced security CMS website operator, I know that it is crucial to flexibly control the display of content in template development, especially for single-page content such as "About Us" and "Contact Us" that may require dynamic judgment and display.In actual operation, we often need to decide whether to render a block or link based on the existence of the page to ensure the accuracy of the website content and the user experience.Below, I will elaborate on how to determine if a single page exists in the Anqi CMS template and display its content.###

2025-11-06

How to retrieve the list of all single pages using the `pageList` tag and display it on the front end?

As a senior person who is deeply familiar with AnQiCMS (AnQiCMS) operation, I know that content is the core position in website construction.The single page acts as the cornerstone for carrying corporate core information, service introduction, contact information, and other static content. Its effective display is crucial for users to understand the website and the corporate image.This article will elaborate on how to use the built-in `pageList` tag of AnQiCMS to retrieve and flexibly display all single page content on the frontend.### Master the `pageList` tag to build a clear single-page navigation and display In AnQiCMS

2025-11-06

`pageDetail` tag can call which detailed information of a single page (such as ID, title, content)?

As an experienced enterprise CMS website operation person, I know that efficient content management is crucial for the success of the website.The single page is an important part of the website architecture, carrying core static information such as 'About Us', 'Contact Information', and 'Terms of Service'.The Anqi CMS provides a powerful `pageDetail` tag, allowing operators to flexibly call and display various detailed information on a single page.The `pageDetail` tag is a data call tool designed specifically for single-page content in the Anqi CMS template engine

2025-11-06

How to correctly call the `Link` single page link in the template?

As an experienced security CMS website operator, I know that correctly calling content links in templates is crucial for website user experience and search engine optimization.The single page is a key part that carries static information such as 'About Us' and 'Contact Information', and the accurate calling of its links is an indispensable part of daily operation. I will elaborate in detail on how to correctly call single-page links in the Anqi CMS template.### Understanding Single Page Links in AnQi CMS In AnQi CMS, a single page (also known as a "page") exists independently of content models such as articles, products, and the like.

2025-11-06

Can the creation time or update time of a single page be retrieved and displayed?

In the operation practice of Anqi CMS, we often pay attention to the time information of the release and update of website content.This is crucial for search engine optimization (SEO) and for users to understand the timeliness of content.Whether the creation time or update time of a single page (Page) can be obtained and displayed, a detailed analysis based on the document provided by Anqi CMS can lead to a clear conclusion.The 'Page Management' feature of AnQi CMS is mainly used to create and manage independent static content pages, such as 'About Us', 'Contact Information', etc.

2025-11-06

How to call single page data from other sites in a multi-site environment?

As an experienced CMS website operation person, I am well aware of the core position of content in website operation.How to efficiently and flexibly call and manage content in a multi-site environment, especially for single-page data, is a real challenge for many operators.AnQi CMS relies on its powerful multi-site management capabilities to provide us with an elegant solution. ### Content Sharing Strategy in the Multi-site Environment of Anqi CMS From the outset, Anqi CMS has taken into account the needs of enterprises and content operation teams for multi-site management.

2025-11-06

How to configure a canonical URL for a single page to optimize SEO?

As a website operator who has been deeply involved in AnQiCMS for many years, I am well aware of the profound impact that every detail has on SEO optimization in content creation and publication.The canonical URL is one of the often overlooked elements that are crucial for search engine rankings and website health.It can effectively solve the problem of duplicate content, concentrate the page weight, and is an effective tool to improve SEO performance.I will elaborate in detail on how to configure standard links for single pages in AnQiCMS

2025-11-06