How to dynamically set the page title (Title), keywords (Keywords) and description (Description)?

Calendar 👁️ 73

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="

Related articles

How to retrieve and display all articles associated with a specific tag?

AnQi CMS: Accurately locate and display the list of articles under specific tags In AnQi CMS, the Tag is a very practical feature that can help us classify and manage website content more finely, improve the efficiency of users discovering relevant content through keywords, and also greatly benefit the SEO performance of the website.By adding meaningful tags to articles, we can link together similar topics scattered across different categories, providing users with a more cohesive and in-depth reading experience.This article will delve into how to make use of the powerful template tag features of AnQi CMS

2025-11-09

How to display a list of all used tags (Tags) in the website?

In website operation, tags are an important tool for content organization and user discovery.A clear and complete list of tags can not only help users quickly find the content they are interested in, but also improve the website's SEO performance and guide search engines to better understand the structure of the website content.AnQi CMS provides powerful and flexible tag management and display functions, allowing you to easily display a list of all tags used on the website.### The display method of the site-wide tag list If you wish to establish a dedicated page on the website to showcase all used tags

2025-11-09

How to retrieve and display detailed content of a specific independent page?

Our Anqi CMS provides great flexibility in content management, especially for pages that need to display independent, static information, such as "About UsThese are called "independent pages" or "single pages", their content is usually relatively fixed, but they also need to be independently displayed and have search engine friendly features.How can we efficiently retrieve and display the detailed content on these specific independent pages in AnQi CMS?

2025-11-09

How to display a list of all independent web pages of the website?

In AnQiCMS, the independent pages of a website play a crucial role, usually carrying core information such as "About Us", "Contact Information", "Privacy Policy", etc. They are an indispensable part of building website trust and perfecting the information architecture.This article will introduce how to effectively manage and display these independent page lists in Anqi CMS. ### Understanding the 'Independent Page' in AnQi CMS In the context of AnQi CMS, what we refer to as the 'Independent Page' corresponds to the 'Single Page' feature in the system.These pages and articles

2025-11-09

How to display the website name and logo in the template?

The website's name and logo, like a person's name and face, are an indispensable symbol.They are not only the core of the brand image, but also the key to improving the professionalism of the website, enhancing user trust, and making it easy to remember.In AnQiCMS, elegantly present these important identification elements in the website template, simpler and more flexible than you imagine.Understanding the basic settings of AnQiCMS website In AnQiCMS, the basic information of the website such as the name and Logo is concentrated in the background "Global Function Settings".You can log in to the back end and navigate to

2025-11-09

How to display the website filing number and copyright information in the footer?

In website operation, the website footer usually contains important information, such as filing number and copyright statement.This information is not only a manifestation of the website's compliance, but also a window for displaying the website's professionalism.AnQiCMS provides a convenient way to manage and display this information.We will introduce in detail how to display the filing number and copyright information in the footer of the AnQiCMS website.

2025-11-09

How to display breadcrumb navigation on a page to improve user experience?

In modern web design, breadcrumb navigation has become a standard element to enhance user experience and website usability.It acts as a guide for users to advance, clearly showing the user's current position in the website's hierarchy structure and providing a convenient way to return to the parent page.For websites built using AnQiCMS, integrating breadcrumb navigation can greatly facilitate visitors and also play a positive role in search engine optimization (SEO).Why is breadcrumbs navigation so important? Imagine

2025-11-09

How to display the contact information, phone number, address, and other contact methods set on the website?

In modern website operation, clearly displaying the company's contact information is a key link in building trust and facilitating communication with users.AnQiCMS (AnQiCMS) knows this well, providing you with an intuitive and flexible backend settings, allowing you to easily manage and display the contact information, phone number, address and other information of the website.This article will introduce in detail how to set and display these important contact information in Anqi CMS.### One, configure your contact information in the Anqi CMS backend All contact information displayed on the website front end first needs to be unified managed in the Anqi CMS backend

2025-11-09