In website operation, Search Engine Optimization (SEO) is a key link to enhance website visibility.While the page title (Title) and description (Description) are the first information seen by search engines and users when browsing, their importance is self-evident.AnQiCMS (AnQiCMS) understands this, and therefore provides a flexible and powerful mechanism for acquiring and displaying these SEO elements in the template.
An overview of AnQi CMS's TDK (Title, Description, Keywords) mechanism
The Anqi CMS takes an intelligent hierarchical and context-aware mechanism when handling page TDK.This means that when you access different page types (such as article detail pages, category list pages, single pages, even the website homepage), the system will automatically determine the type of the current page and will preferably try to obtain the SEO title and description configured for the page itself.
In particular:
- Content level priority:If you set SEO title and description for an article, a category or a single page in the backgroundindividually, the system will prioritize using this content.
- Content field extraction:If the content itself does not have a clear SEO description field, or if you have not filled it in, the system will intelligently extract a portion of text from the 'summary' field (such as the 'document summary' of an article, or the 'category summary' of a category) as the page Meta Description.
- Global settings fallback:If neither of the above two has obtained valid content, the system will fall back to the global title and description configured in the "Homepage TDK Settings".
This mechanism ensures that the website will have a reasonable and SEO-friendly title and description, regardless of whether you have fine-tuned the TDK configuration for each page.
核心:Universal TDK Tag——{% tdk %}
The most convenient and recommended way to get page SEO title and description in Anqi CMS template design is to use the universal.{% tdk %}Tag. The magic of this tag is that it can intelligently output the most suitable SEO information according to the context of the current page.
To get the SEO title of the current page, you can use it in the template's<head>area:
<title>{% tdk with name="Title" %}</title>
This code will automatically output the title of the page you visit.For example, if accessing the article detail page, it will output the SEO title (or article title) of the article; if accessing the category list page, it will output the SEO title (or category name) of the category; if it is the homepage, it will output the title set in the homepage TDK settings.
Similarly, it's very simple to get the SEO description and keywords of the current page:
<meta name="description" content="{% tdk with name="Description" %}">
<meta name="keywords" content="{% tdk with name="Keywords" %}">
Here are thename="Description"andname="Keywords"Parameters are used to indicate the description and keywords of the page to be fetched by the label.
Flexible control of title display
{% tdk with name="Title" %}The label also provides additional parameters to allow for more flexible control of the title display.
Additional Website Name:很多时候,我们希望页面标题在搜索引擎中显示为“页面标题 - 网站名称”或“页面标题 | 网站名称”。你可以通过
siteName=trueandsepTo implement:<title>{% tdk with name="Title" siteName=true sep=" | " %}</title>Here, the page content will be
<title>automatically combined into[当前页面标题] | [网站名称]the form, for example, 'AnQi CMS Template: Get SEO Title and Description | AnQi CMS Official Website'.sepThe parameter is used to define the delimiter, the default is-.display the parent category title:In some category list pages or detail pages, you may want the title to include the name of its parent category, which can be achieved by
showParent=truethe parameter.
深度定制:直接获取文档/分类/页面SEO信息 (English)
Although{% tdk %}The label is already smart enough to meet most needs, but in some special cases, you may need to directly obtain the SEO field values of specific documents, categories, or single pages instead of{% tdk %}Label intelligent combination result.
For example, if you want to display the SEO title of a document separately in a certain area of a document detail page, rather than using it as the page's<title>Label content, you can usearchiveDetailTags:
{% archiveDetail with name="SeoTitle" %}
Similarly, for the category page:
{% categoryDetail with name="SeoTitle" %}
{% categoryDetail with name="Description" %}
{% categoryDetail with name="Keywords" %}
For single-page:
{% pageDetail with name="SeoTitle" %}
{% pageDetail with name="Description" %}
{% pageDetail with name="Keywords" %}
These tags will directly output the corresponding content type (document, category, single page) SEO field values configured in the background. Generally speaking, we recommend using them in priority.{% tdk %}Label to build the page standard<title>and<meta>Label, as it can better handle various page types and fallback logic for un设定的content.And directly accessing specific fields is more suitable for scenarios where it is necessary to display these original SEO data as part of the page content.
Actual operation steps
It is very direct to apply these labels to your website template:
定位template file:Generally, the public header of the website (including
<head>labels) is concentrated in a file namedbase.htmlIn a template file named or similar, located in the current topic of you,/templatethe directory.Find
<head>area:Find it in this file,<head>to</head>Between the code blocks.Insert the TDK tag:In
<head>In the area, replace or add the following code:`html <!DOCTYPE html>
<meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- 页面SEO标题 --> <title>{% tdk with name="Title" siteName=true sep=" - " %}</title> <!-- 页面SEO关键词 --> <meta name="keywords" content="{% tdk with name="Keywords" %}"> <!-- 页面SEO描述 --> <meta name="description" content="{% tdk with name="Description" %}"> <!-- 其他head内容... --><!-- 网站内容 -->