How to dynamically generate page title, keywords, and description with the `tdk` tag and flexibly control whether to include the website name?

Calendar 👁️ 71

In website operation, the page title (Title), keywords (Keywords), and description (Description), which we commonly refer to as TDK, are the foundation of search engine optimization.They not only help search engines understand page content, but are also key factors in attracting user clicks.AnQiCMS (AnQiCMS) fully understands the importance of TDK, through its powerful template tag system, especially the versatiletdkTags make it easy and efficient to dynamically generate and flexibly control page TDK.

How to dynamically generate TDK: The intelligent mechanism of Anqi CMS.

Of Security CMStdkThe tag design is very intelligent, it can automatically identify and capture the most relevant TDK information based on the type of the current page (such as the homepage, article detail page, category list page, single page, or tag page). This mechanism has a clear priority:

  1. Content level TDK priority:When you set SEO titles, keywords, and descriptions for specific articles, products, categories, single pages, or tags in the background,tdkLabels will prioritize this information. For example, the "SEO Title", "Keywords", and "Description" entered in the "Publish Document" or "Edit Category" interface.
  2. Home page TDK fallback:If the current page does not have a specific TDK setting,tdkthe tag will revert to the content defined in the "Home TDK Setting" in the "Background Setting".

This means, you only need to fill in the content as needed when publishing,tdkTags can automatically display the most appropriate TDK on the front end, greatly reducing redundant work and ensuring fine-grained SEO management.

tdkThe application of tags in templates.

Apply TDK in your AnQi CMS website template, usually you need toheadusing tags insidetdktag to call the corresponding data.

1. Dynamically generate page titles (name="Title")

The page title is the most important element in TDK.tdkThe tag provides rich flexibility when obtaining the page title.

Basic usage:

The simplest way to call in the template is:

<title>{% tdk with name="Title" %}</title>

This simple code can make AnQiCMS automatically output the most suitable page title based on the context of the current page.For example, on the article detail page, it will display the SEO title of the article;On the category page, it displays the category name; on the homepage, it displays the homepage title.

Flexibly control whether to include the website name (siteNameparameter):

AnQiCMS'tdkThe tag provides a very practicalsiteNameParameter, allowing us to flexibly control whether the page title includes the website name. By default,siteNameIsfalseIt means that the website name will not be automatically appended to the title.

  • If you want the website name to be displayed after the page titlesimply set the parameter tositeName=trueand it is done:

    <title>{% tdk with name="Title" siteName=true %}</title>
    

    For example, if the article title is “AnQi CMS template making tutorial”, and the website name is “AnQi CMS”, then the output title may be “AnQi CMS template making tutorial - AnQi CMS”.

  • If you do not want the website name to appear in the page titleor you want to manually control the display position and format of the website name, you can keepsiteName=false(or not write this parameter, as the default is already}false),then concatenate as needed.

    <title>{% tdk with name="Title" siteName=false %} - 我的自定义网站名</title>
    

    On a specific page, you can fully customize the way the website name is displayed to ensure consistency with your brand strategy.

Custom separator (sepparameter):

By default,tdkTags are used when combining the title and the website name-As a separator. If you have different needs, for example, you want to use_or|can be accessed throughsepSet the parameter:

<title>{% tdk with name="Title" siteName=true sep="_" %}</title>

In this way, your title will become 'Page Title_Website Name'.

Display the parent category title (showParentparameter):

For some category pages, we may want to reflect the parent category in the title.showParentThe parameter can bename="Title"effective attruewhen set to, the title will include the name of the parent category:

<title>{% tdk with name="Title" showParent=true %}</title>

2. Dynamically generate page keywords (name="Keywords")

Page keywords (Keywords) although their weight has decreased in modern SEO, they are still an important part of the page information.tdkThe label can automatically obtain keywords set in the background.

<meta name="keywords" content="{% tdk with name="Keywords" %}">

HereKeywordsContent is prioritized from the 'Keywords' field of the current page (article, category, single page, tag), if not set, it will fallback to the 'Home Page TDK' keywords.

3. Dynamically generated page description (name="Description")

Page description (Description) is a summary displayed to users on the search engine results page (SERP), directly affecting click-through rate.

<meta name="description" content="{% tdk with name="Description" %}">

DescriptionThe content will be prioritized from the 'Introduction' field of the current page (article, category, single page, tag), if not set, it will fallback to the 'Home Description' in the home TDK.

4. Dynamically generate page specification link(name="CanonicalUrl")

The canonical URL is crucial for avoiding duplicate content issues, as it tells search engines which is the preferred version of the page.tdkLabels can dynamically obtain this value.

{%- tdk canonical with name="CanonicalUrl" %}
{%- if canonical %}
<link rel="canonical" href="{{canonical}}" />
{%- endif %}

Here we first assign theCanonicalUrlAssign the value tocanonicalA variable, and then through aifJudgment to ensure that the standard link exists before outputtinglinkTag, this is a good practice to avoid outputting empty.canonical.

**Practice of TDK application

In order to maximizetdkTags in the effect of SEO, there are several tips worth sharing:

  • The uniqueness of TDK:Ensure that the TDK of each important page is unique and highly relevant. Avoid repetition, even for similar pages, and maintain subtle differences.
  • Keyword layout:Naturally integrate the core keywords into the title and description, avoiding repetition.
  • Attractiveness of the description:The page description should be concise and clear, able to attract users to click. It can be regarded as advertising copy.
  • Length control:The title is generally recommended to be within 60 characters, and the description within 120-150 characters to ensure complete display on the search engine results page.
  • Habits of TDK settings in the background:When publishing any new content (articles, products, categories, single pages, tags), it is a good habit to fill in the SEO title, keywords, and description, which can make full use oftdkThe dynamic ability of tags, avoid using default values.

By making reasonable use of the Anqi CMS'stdkTags with rich parameters, you can not only manage the website's TDK information efficiently, but also for the website's

Related articles

How to use the `stampToDate` tag to format a timestamp into a custom date and time format?

Good, I'm glad to deeply interpret the `stampToDate` tag of AnQiCMS, helping you easily control the time display on the website. --- ## Flexible Time Mastery: Customize Date and Time Format with AnQiCMS `stampToDate` Tag The way dates and times are displayed on a website often directly affects user experience and the clarity of information communication in content management.A concise and readable date format allows visitors to quickly understand the timeliness of the content. AnQiCMS

2025-11-07

How to correctly configure the `pagination` tag to generate a functional pagination navigation on the list page?

In website content management, configuring a fully functional pagination navigation for the list page is a key factor in improving user experience and optimizing the website structure.AnqiCMS (AnqiCMS) provides a simple and powerful `pagination` tag, allowing developers to easily meet this need.To make the `pagination` tag generate the pagination navigation correctly on the list page, it is first necessary to understand its mechanism and the collaborative relationship with content list tags (such as `archiveList`).

2025-11-07

How to get and paginate the display of all relevant documents under a specific `tagDataList` tag?

When managing content in Anqi CMS, tags (Tag) are an important tool for organizing and categorizing information.It can not only help users quickly find relevant content, but also significantly improve the internal link structure and SEO performance of the website.When it is necessary to display all relevant documents under a specific tag and to manage pagination, the `tagDataList` tag becomes an indispensable core function.

2025-11-07

How to use the `prevArchive` and `nextArchive` tags to navigate to adjacent documents in the article detail page?

In today's content-driven world, the user experience of the website article detail page is particularly important.When a reader is immersed in an excellent content, if they can navigate smoothly to related or adjacent articles, not only can it extend their stay on the website and increase the page views, but it can also indirectly optimize the search engine crawling and ranking through the internal link structure.AnQi CMS is an efficient and SEO-friendly content management system that fully considers these details and provides simple and intuitive template tags to help us easily achieve this function. Today

2025-11-07

How to construct a website navigation with multi-level submenus and associated content using the `navList` tag?

When building a website, a clear and easy-to-use navigation system is crucial, as it directly affects whether users can quickly find the information they need and also influences how search engines understand the structure of the website.AnQiCMS provides a powerful `navList` tag, allowing us to flexibly build a navigation system with multi-level submenus and closely associate navigation items with website content.Next, we will delve into how to use the `navList` tag to create a set of multi-level navigation that is both beautiful and practical for your website.### Website Navigation Basics

2025-11-07

How to create a dynamic breadcrumb navigation using the `breadcrumb` tag and customize the home page name and title display?

In website operation, a clear navigation path is crucial for user experience and search engine optimization (SEO).Breadcrumb Navigation is like a small map of a website, allowing visitors to always know their location and easily return to the previous page.Today, let's delve deeper into how to use the powerful `breadcrumb` tag in Anqi CMS to create dynamic breadcrumb navigation and customize the home page name and title display according to our needs.

2025-11-07

How to perform content filtering, batch replacement, and recycle bin operations in the document management feature of the AnQiCMS backend?

The content management system is the core of website operation, especially for sites that update content frequently, efficient document management functions are crucial.AnQiCMS as a powerful content management system, provides a rich and practical background document management tool, helping operators easily handle daily content maintenance work.This article will delve into the functionality of AnQiCMS backend in content filtering, batch replacement, and recycle bin operations, helping you manage website content more efficiently.### Efficient Filtering: Quickly Locate Target Content Quickly locate the required information in the vast amount of website content

2025-11-07

How to create and manage custom content models in AnQiCMS and add specific fields to them?

In daily website operations, we often encounter the need to publish various types of content.In addition to common articles and product displays, you may also need a dedicated "event list" to post the latest events, or a "team members" page to showcase the core team of the company, or even a "successful case" module to share project experience.AnQiCMS was designed with this flexibility in mind, providing powerful custom content model features, allowing us to flexibly create and manage different types of content structures according to our actual business needs. So

2025-11-07