How to dynamically generate page Title, Keywords and Description using `tdk` tag in AnQiCMS template?

Calendar 👁️ 74

In today's internet environment where content is exploding, Search Engine Optimization (SEO) is crucial for the visibility of websites.And the Title (title), Keywords (keywords), and Description (description) of the website page, which we commonly refer to as TDK, are the key factors that search engines understand the content of the page, decide whether to display it to users, and whether users click.In AnQiCMS, a content management system designed specifically for small and medium-sized enterprises and content operation teams, flexibly and dynamically generating these TDK information is a powerful tool to improve website SEO performance and optimize user experience.

AnQiCMS with its high efficiency and customizable features provides powerful SEO tools, including fine-grained control over TDK.It is not just a static field entry, but also a dynamic mechanism that can be automatically generated or manually overridden based on the page type and content attributes.Next, we will delve into how to cleverly usetdkTags to dynamically generate page Title, Keywords, and Description.

How does AnQiCMS manage TDK information?

In AnQiCMS, the management of TDK information is hierarchical, which gives the website great flexibility:

  1. Global default settings (home page TDK):First, you can configure the default Title, Keywords, and Description for the entire website's homepage in the 'Background Settings' -> 'Home Page TDK Settings' of the AnQiCMS backend.These are the most basic and core SEO statements of the website, when a specific page does not have a separate TDK setting, the system may use these global settings as a fallback (especially on the home pages of certain default templates).

  2. Content hierarchy settings (articles, products, single pages, categories, tags):In addition to global settings, AnQiCMS allows you to define independent TDK for each specific page in different content editing interfaces:

    • Document (articles, products, etc.) publishing:When adding or editing a document, you can find fields such as 'SEO Title', 'Document Keywords', and 'Document Summary'.Among them, the "SEO Title" will be the preferred content for Title, while the "Document Summary" is usually used for Description.
    • Category Management:When creating or editing a category, there are also options such as "SEO Title", "Keywords", and "Category Description". These settings will affect the list page of the category.
    • Single page management:For independent pages such as "About Us", "Contact Us", etc., there are also independent "SEO Title", "Keywords", and "Single Page Introduction" for you to configure.
    • Document Tag:Even on the tag page, AnQiCMS provides settings for 'SEO Title', 'Tag Keywords', and 'Tag Description' to ensure that each page is optimized.

This hierarchical management mechanism means that you can first set a general TDK strategy, and then make refined adjustments for important or special pages to achieve the best SEO coverage.

Core tags:tdkUsage of

AnQiCMS's template system is very powerful and easy to use, it uses syntax similar to the Django template engine. To dynamically obtain and display TDK information, we mainly rely onUniversaltdkTag.

tdkThe basic usage of tags is:{% tdk 变量名称 with name="字段名称" %}. Where, 'variable name' is optional, if you want to assign the obtained value to a variable for subsequent processing, you can specify it; if not specified, thentdkThe label will directly output the result.nameThe parameter specifies which type of TDK information you want to obtain.

1. Dynamically generate page Title

The page's Title is one of the most important SEO elements. UsetdkLabel acquisition Title is very intuitive, and AnQiCMS provides a wealth of parameters to meet the needs of different scenarios.

To get the title of the current page, it is usually written in the template's<head>area like this:

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

But AnQiCMS has given Title more dynamic features:

  • Attach website name:The Title format of many websites is "Page Title - Website Name". You cansiteName=trueautomatically append the website name with parameters:

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

    This, if your page title is "AnQiCMS Tutorial", the website name is "AnQiCMS", the final Title may display as "AnQiCMS Tutorial - AnQiCMS".

  • Custom separator:Under default conditions, the website name and page title are separated by a hyphen-You can usesepParameter custom separator:

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

    At this time, the Title will display as "AnQiCMS Tutorial_AnQiCMS".

  • Display parent category title:For content with a hierarchical structure (such as an article detail page), you may want the Title to include the name of its parent category to provide a more complete context.showParent=trueThe parameter can achieve this:

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

    Assuming the article "Dynamic Generation TDK" belongs to the "Template Creation" category, the Title may display as "Dynamic Generation TDK - Template Creation - AnQi CMS".This is very helpful for search engines to understand the breadth and depth of the page topic.

By combining these parameters, you can implement a highly customized dynamic generation strategy for the website's Title, whether it's the homepage, category page, or detail page, it can automatically adapt and display the Title that best meets SEO requirements.

2. Dynamically Generate Page Keywords

Keywords tags have decreased in weight in modern SEO, but they still provide auxiliary information about the page topic to search engines.In AnQiCMS, Keywords will be automatically obtained from the corresponding backend settings of the page (article keywords, category keywords, etc.).

In the template, you can introduce Keywords in this way:

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

Or, if you want to assign the content of the keyword to a variable:

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

Make sure you have set the relevant keywords for each page in the background, which will be dynamically extracted and displayed here.

3. Dynamic Page Generation Description

The description tag is the summary displayed below the title in the search engine results page, which directly affects the user's click intention.A clear and attractive Description is crucial for improving click-through rate.AnQiCMS will automatically obtain from the corresponding backend settings of the page (document introduction, category introduction, etc.).

In the template, you can introduce Description as follows:

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

Similar to Keywords, you can also assign it to a variable:

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

A good Description should concisely summarize the page content, include relevant keywords, and attract potential visitors to click.

4. Dynamically Generate Canonical URL (Canonical URL)

The canonical URL is an advanced SEO concept, used to inform search engines of the preferred URL for a page, to avoid negative SEO impacts due to content duplication (such as multiple URL paths, pagination content, etc.).AnQiCMS also supports dynamically generating Canonical URLs for pages.

Since not all pages need or will have an independent Canonical URL, **the practice is to first determine if it exists before setting it:**

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

This code attempts to retrieve the Canonical URL of the current page, if it is set in the background (such as in the document editing interface), it will be rendered; otherwise, it will not output, avoiding unnecessary empty tags.

Practice case and **practice

In order to make the TDK configuration more efficient and unified, we strongly recommend that you create a public header file in the AnQiCMS template (for examplepartial/_header.html),and place all TDK-related tags together, then reference them through{% include "partial/_header.html" %}in all pages.

A typicalpartial/_header.htmlThe example may be as follows:

``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 showParent=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}}" />

Related articles

How to display the introduction and Banner image of the current category in the AnQiCMS template?

How to make your category page on the website more attractive while clearly conveying information is the key to improving user experience and SEO effectiveness.AnQiCMS (AnQiCMS) with its flexible template system allows you to easily display the introduction of the current category and personalized Banner images on the category page. We will explore together how to implement this feature in the AnQiCMS template, making your website category page more vivid and professional.### 1. Deeply understand the AnQiCMS template system AnQiCMS

2025-11-09

How to display hreflang tags for users of different languages on the AnQiCMS website?

In the operation of multilingual websites, it is crucial to ensure that search engines can accurately understand the language and region targeted by your content, which is essential for improving user experience and search engine optimization (SEO).The `hreflang` tag is the key tool to solve this problem.It tells search engines that your site has content variants for different languages or regions, thus avoiding duplicate content issues and helping search engines to display the most relevant pages to users of different languages.

2025-11-09

How to format the timestamp into the display format of 'Year-Month-Day Hour:Minute' in AnQiCMS template?

In website content management, the clear display of time information is crucial for user experience.Whether it is the release date of an article or the submission time of comments, a format that conforms to reading habits can make information communication more effective.AnQiCMS provides flexible template functionality, allowing us to easily format timestamps.

2025-11-09

How to display the user nickname, comment content, and posting time in the AnQiCMS comment list?

In AnQiCMS, the comment feature is an important part to enhance the interaction of the website.How to clearly and beautifully display the valuable comments left by users on the website, which is a focus for website operators.AnQiCMS provides flexible template tags, allowing us to easily customize the display of the comment list, including user nicknames, comment content, and publishing time, etc.To implement the display of comment lists, we mainly use the AnQiCMS template tag system.This usually involves editing the specific parts of the website template file. ### 1.

2025-11-09

How to implement multi-condition filtering display on the article list page with the `archiveFilters` tag of AnQiCMS?

It is crucial to provide users with a convenient and accurate content search experience in website operation.As the content of the website becomes richer, simple classification or keyword search is often not enough to meet the personalized needs of users.At this time, the multi-condition filtering function on the article list page is particularly important.For AnQiCMS users,巧妙利用 `archiveFilters` tag can easily achieve this goal, making your article list page instantly possess powerful filtering capabilities.

2025-11-09

How to automatically convert plain text URLs of articles in the AnQiCMS template to clickable hyperlinks?

In daily website content operations, we often need to mention some external links or URLs in articles, product descriptions, or single-page content.If these URLs appear only in plain text, visitors will not be able to click and jump directly, which will undoubtedly affect the user experience, and may even cause some important information to be ignored.AnQiCMS as a powerful content management system, provides a simple and efficient way to solve this problem, making your content more vivid and interactive.AnQiCMS uses a template engine syntax similar to Django

2025-11-09

How to prevent content scraping on the front end in AnQiCMS, such as displaying watermarks or interference codes?

Protect Originality: AnQiCMS intelligent strategy for front-end content collection prevention In the era of explosive Internet content, the value of original content is becoming more and more prominent, but it also faces the risk of malicious collection.The hard work we put into writing and carefully designed images can be stolen in an instant by others, not only infringing on the creators' labor成果, but also potentially affecting the website's SEO performance and brand image.How can we effectively protect our digital assets?AnQiCMS (AnQiCMS) provides a very practical built-in solution to this issue

2025-11-09

How to use the `if` tag in AnQiCMS templates for conditional judgment to control content display?

When managing content in AnQi CMS, we often need to display different information based on different situations.For example, a blog post may have a thumbnail, while another does not; or a module may only display under certain conditions.At this time, flexibly using the conditional judgment in the template, that is, the `if` tag, can help us achieve these dynamicized content display needs.The AnQi CMS template engine supports syntax similar to Django, where the `if` tag is the core tool for conditional judgments.

2025-11-09