In website operation, Search Engine Optimization (SEO) is the key to improving website visibility.And the page title (Title) and description (Description) as the first information seen by search engines and users browsing, their importance is self-evident.AnQiCMS (AnQiCMS) knows this, and therefore provides a flexible and powerful mechanism in the template to retrieve and display these SEO elements.
AnQi CMS TDK (Title, Description, Keywords) mechanism overview
The Anqi CMS takes an intelligent hierarchical and context-aware mechanism when handling page TDK.This means that when you visit different page types (such as article detail pages, category list pages, single pages, even the website homepage), the system will automatically judge the type of the current page and try to get the SEO title and description configured for the page itself first.
In particular:
- Content level priority:If you set SEO title and description for an article, a category or a single page in the backgroundindividuallythe system will use this content first.
- Content field extraction:If the content 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 the article, the "Category Summary" of the category) as the page Meta Description.
- Global settings fallback:If neither of the above two are able to obtain valid content, the system will fallback to the global title and description configured in the 'Homepage TDK settings'.
This mechanism ensures that whether or not you have performed fine-grained TDK configuration for each page, the website will have a reasonable and SEO-friendly title and description.
Core: Universal TDK Tag -{% tdk %}
The most convenient and recommended way to get the page SEO title and description in Anqi CMS template design is to use the universal {% tdk %}The tag is amazing because it can intelligently output the most suitable SEO information based on 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 are visiting.For example, if you visit the article detail page, it will output the SEO title (or article title) of the article;If the category list page is accessed, it will output the category's SEO title (or category name);If it is the homepage, it will output the title from the homepage TDK settings.
Similarly, getting the SEO description and keywords of the current page is also very simple:
<meta name="description" content="{% tdk with name="Description" %}">
<meta name="keywords" content="{% tdk with name="Keywords" %}">
Herename="Description"andname="Keywords"Parameters are used to indicate the label to retrieve the page description and keywords.
Flexible control of title display
{% tdk with name="Title" %}The label also provides additional parameters to allow you to control the title display more flexibly.
Attach website name:Many times, we want the page title to be displayed in search engines as "Page Title - Website Name" or "Page Title | Website Name". You can do this by
siteName=trueandsepParameter to implement:<title>{% tdk with name="Title" siteName=true sep=" | " %}</title>This page,
<title>the tag content will automatically combine to form[当前页面标题] | [网站名称]such as "AnQi CMS template: Get SEO title and description | AnQi CMS official website".sepParameters are used to define delimiters, the default being-.Display 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=truethis parameter.
Deep customization: Directly obtain document/category/page SEO information
Although{% tdk %}The tag 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, rather than by{% tdk %}The result of intelligent label combination.
For example, if you want to display the SEO title of the document separately in a certain area of the document detail page, instead of 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 a single page:
{% pageDetail with name="SeoTitle" %}
{% pageDetail with name="Description" %}
{% pageDetail with name="Keywords" %}
These tags will directly output the corresponding SEO field values configured for the content type (document, category, single page) in the background. Generally speaking, we recommend using them first.{% tdk %}Standard to build page tags<title>and<meta>The tag, because it can better handle various page types and the fallback logic for content that has not been set.The direct way to obtain 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 tags to your website template:
Locate the template file:Generally, the public header of the website (including
<head>tags) is concentrated in a namedbase.htmlIn a template file with a similar name, located in the current topic of/templatedirectory.Find
<head>Area:Find in this file,<head>to</head>the code block between.Insert TDK tags: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内容... --><!-- 网站内容 -->