In website operation, the page title (Title), keywords (Keywords), and description (Description) are the foundation of search engine optimization (SEO).They not only convey the core information of the page content to search engines but also directly affect the click-through rate of users on the search results page.AnQiCMS (AnQiCMS) fully understands its importance and provides a flexible and powerful mechanism that allows users to dynamically and accurately set these SEO elements based on the content of different pages.

This article will discuss in detail how to efficiently and dynamically manage and set the title, keywords, and description of the page in AnQiCMS.


The core tool in AnQiCMS: Universal TDK Tag

AnQiCMS provides a very convenient 'universal' tag for dynamically setting TDK tags——tdk. This tag is clever in that it can intelligently grab and output the corresponding title, keywords, and description based on the type of the current page (such as the homepage, article detail page, category list page, or single page).This means, you don't need to write complex logic judgments for each page type, just call it once in the templatetdkTags, the system will automatically complete the match.

tdkTags are usually used in the following ways, throughnameParameters to specify the specific content you want to obtain:

  • name="Title": used to get the page of the<title>Tag content.
  • name="Keywords": used to get the page of the<meta name="keywords">Content.
  • name="Description": used to get the page of the<meta name="description">Content.
  • name="CanonicalUrl"Used to obtain the standard link of the page (<link rel="canonical">).

In addition, when you usename="Title"you can also customize the display style of the title by using additional parameters:

  • siteName=trueorsiteName=false: Decide whether to append the website name after the title. Default is not appended.
  • sep="分隔符":Customize the separator between the website name and the page title, default to-.
  • showParent=trueorshowParent=false: Decide whether to display the title of the parent category on the category or document page. Default isfalse.

Dynamically set TDK: varies by page

AnQiCMS's dynamic TDK settings follow a clear priority rule, ensuring that each page can have the most accurate SEO information.

1. Home page TDK settings

The homepage acts as the gateway of the website, and the setting of its TDK is particularly critical.In the AnQiCMS backend, you can go to the "Backend Settings" under the "Home TDK Settings" area to configure exclusive titles, keywords, and descriptions for your website's homepage.These settings will serve as the important foundation and default fallback for the entire website TDK.

In the template, you can call the home page TDK in the following way:

<title>{% tdk with name="Title" siteName=true sep="_" %}</title>
<meta name="keywords" content="{% tdk with name="Keywords" %}">
<meta name="description" content="{% tdk with name="Description" %}">

2. TDK settings for document detail page (article/product)

For specific article or product detail pages, AnQiCMS allows you to perform highly customized TDK settings when publishing or editing documents. In the "Add Document" or "Edit Document" interface, there is usually a collapsed area for "Other Parameters" or "SEO Settings" where you can find:

  • SEO titleThis field will be directly used as the page of the document<title>The content has a higher priority than the default system and category settings
  • Document keywordYou can manually enter or select from the keyword library as the page of the document<meta name="keywords">.
  • Document IntroductionIf no separate description is set, the system will prioritize extracting the introduction from here for the page<meta name="description">If the document summary is not filled in, the system will automatically extract the first 150 characters from the document content as the description.
  • Canonical Link (Canonical Url): Used to specify the standard URL of the page, which helps to avoid duplicate content issues.

In the template of the document detail page,tdkThe tags will intelligently extract these targeted settings:

<title>{% tdk with name="Title" siteName=true %}</title>
<meta name="keywords" content="{% tdk with name="Keywords" %}">
<meta name="description" content="{% tdk with name="Description" %}">
{%- tdk canonical with name="CanonicalUrl" %}
{%- if canonical %}
<link rel="canonical" href="{{canonical}}" />
{%- endif %}

As you can see,tdkThe tag on the document detail page can automatically identify and prioritize the SEO title, keywords, and description that you have individually set in the background for this document.

3. Category list page TDK settings

Each category can have its own independent SEO information. When editing a category in the 'Document Category' management page of the AnQiCMS backend, you can set the category's parameters in the 'Other Parameters' area:

  • SEO titleFor the category list page,<title>.
  • KeywordsFor the category list page,<meta name="keywords">.
  • Category introductionIf no separate description is set, the system will prioritize extracting the introduction from here for the page<meta name="description">.

In the template of the category list page,tdkThe tags will dynamically read the unique settings of these categories:

<title>{% tdk with name="Title" siteName=true showParent=true %}</title>
<meta name="keywords" content="{% tdk with name="Keywords" %}">
<meta name="description" content="{% tdk with name="Description" %}">

Note hereshowParent=trueA parameter that can include the title of the parent category in the category title, building a more hierarchical page title.

4. TDK settings for a single page

For single pages like 'About Us' and 'Contact Us', the TDK settings are similar to those of document detail pages. When editing individual pages in the 'Page Management' backend, you can also find:

  • SEO title
  • Keywords
  • Single page introduction

tdkThe usage of the tag in the single page template is the same as that of the document detail page, it will prioritize reading these page-level settings.

5. TDK settings of the tag detail page

AnQiCMS also supports setting independent SEO information for each tag (Tag). When editing a tag in the background "Document Tag" management, you can configure:

  • SEO title
  • Tab keywords
  • Tab description

When the user visits a label's detail page,tdkthe label will automatically retrieve and apply these settings.

Complete example: a page header (<head>) of TDK code snippet

In your AnQiCMS template file (usuallybase.htmlor in the header file of each page<head>you can place all TDK-related tags in the block.tdkThe intelligent recognition mechanism of the tags will ensure that they output the correct content according to the context of the current page:

``twig <!DOCTYPE html>

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{# 页面标题,并附加网站名称,使用下划线作为分隔符 #}
<title>{% tdk with name="Title" siteName=true sep="_" %}</title>
{# 页面关键词 #}
<meta name="keywords" content="{% tdk with name="Keywords" %}">
{# 页面描述 #}
<meta name="description" content="{% tdk with name="Description" %}">
{# 规范链接,判断是否存在才输出 #}
{%- tdk canonical with name="CanonicalUrl" %}
{%- if canonical %}
<link rel="canonical" href="{{canonical}}" />
{%- endif %}

{# 其他头部内容,如CSS、Favicon等 #}
<link rel="stylesheet" href="{% system with name="TemplateUrl" %}/css/style.css">
<link rel="icon" href="/favicon.ico" type="