In the AnQiCMS content management system, the management of TDK (Title, Description, Keywords) information for website SEO is a crucial aspect.AnQi CMS provides convenient and powerful template tags for website operators to flexibly call this information on the frontend page.{% tdk %}Tags are special tags used to handle page TDK information.
{% tdk %}The tag is used to obtain the current page's title (Title), keywords (Keywords), and description (Description) etc. SEO meta information in the AnQiCMS template. The basic usage format in the template is{% tdk 变量名称 with name="字段名称" %}. Among them,变量名称It is an optional parameter, if set, the obtained TDK information can be referred to by the variable name later; if not set, the tag will directly output the field content.
Call home page TDK information
Call for home page TDK information,{% tdk %}Tags provide fine-grained control, allowing operators to flexibly display according to actual needs.
Home Title (Title)
The page title is the first impression of search engines and users to understand the content of the page, and for the homepage, it is the direct embodiment of the brand and core business of the website. In AnQiCMS, you can{% tdk with name="Title" %}Call the home page title.
This tag supports additional parameters to adapt to different display scenarios when calling the title. For example,siteNameParameter (boolean type, default asfalse) Can control whether to append the website name after the title. If set tositeName=true, then the home page title will automatically concatenate the website name to form the format "Home Title - Website Name".
At the same time,sepThe parameter allows you to customize the separator between the title and the website name, the default is a hyphen-. By settingsep="_", you can change the separator to an underscore.
showParentParameter (boolean type, default asfalse) Typically used on detail pages or list pages to control whether the title of the parent category is displayed.But when calling on the homepage, this parameter is usually not applicable because the homepage usually does not have the concept of parent categories.
This is an example of calling the home page title
{# 默认调用首页标题,不显示网站名称后缀 #}
<title>{% tdk with name="Title" %}</title>
{# 调用首页标题并显示网站名称后缀 #}
<title>{% tdk with name="Title" siteName=true %}</title>
{# 调用首页标题并使用自定义分隔符(例如下划线)显示网站名称后缀 #}
<title>{% tdk with name="Title" sep="_" siteName=true %}</title>
{# 通过变量名称获取首页标题 #}
<title>{% tdk seoTitle with name="Title" siteName=true %}{{seoTitle}}</title>
Home page keywords (Keywords)
Keywords are important metadata that help search engines understand the core content of a website. In the AnQiCMS template, the home page keyword information can be accessed through{% tdk with name="Keywords" %}Tags can be easily obtained. These keywords are usually filled in the HTML.<meta name="keywords" content="">in the tag.
Here is an example of calling the home page keywords:
{# 默认调用首页关键词 #}
<meta name="keywords" content="{% tdk with name="Keywords" %}">
{# 通过变量名称获取首页关键词 #}
<meta name="keywords" content="{% tdk seoKeywords with name="Keywords" %}{{seoKeywords}}">
Home page description (Description)
The page description is a brief summary of the website content, which is displayed on the search engine results page and affects the user's click intention. Use{% tdk with name="Description" %}Labels can easily insert the home page description in the template, usually used in HTML's<meta name="description" content="">.
Here is an example of how to call the home page description:
{# 默认调用首页描述 #}
<meta name="description" content="{% tdk with name="Description" %}">
{# 通过变量名称获取首页描述 #}
<meta name="description" content="{% tdk seoDescription with name="Description" %}{{seoDescription}}">
Page's canonical URL (CanonicalUrl)
{% tdk with name="CanonicalUrl" %}The tag can call the home page's canonical URL.
Since some pages may not have set a canonical URL, to avoid outputting empty<link rel="canonical">Label, it is recommended to check if it exists before use.
The following is an example of calling the home page specification link:
{# 通过变量名称获取规范链接,并判断其是否存在后输出 #}
{%- tdk canonical with name="CanonicalUrl" %}
{%- if canonical %}
<link rel="canonical" href="{{canonical}}" />
{%- endif %}
Through the above{% tdk %}Flexible use of tags and related parameters, AnQiCMS website operators can efficiently and accurately manage the TDK information on the homepage, laying a solid foundation for search engine optimization.
Frequently Asked Questions (FAQ)
Ask: How can I set the TDK information of the home page in the AnQiCMS background?
Question:{% tdk %}Can tags only be used on the home page? Can I use them to call TDK information on the article detail page?Answer:{% tdk %}The label is not only used on the homepage.It is a universal TDK tag that can be used on any page of the AnQiCMS template.When used on the article detail page, it will call the TDK information set by the article itself; if the article is not set, it will usually fallback to the category's TDK, then to the model's TDK, and finally to the TDK information of the home page.
Why is it recommended to check if the canonical URL exists before calling it?Answer: Not all pages need or have set up a standard link. If it is directly output.link rel="canonical"Tag and itshrefThe property is empty, which may cause the HTML structure to be不规范, and even may be misread by search engines.Therefore, it is good practice to ensure that the tag is only output when the specification link actually exists in the template.