How to retrieve and display the SEO title and description of the current document in the template?

Calendar 👁️ 66

In website operation, Search Engine Optimization (SEO) is the key to improving website visibility.And the page title (Title) and description (Description) as the first information seen by search engines and users browsing, their importance is self-evident.AnQiCMS (AnQiCMS) knows this, and therefore provides a flexible and powerful mechanism in the template to retrieve and display these SEO elements.

AnQi CMS TDK (Title, Description, Keywords) mechanism overview

The Anqi CMS takes an intelligent hierarchical and context-aware mechanism when handling page TDK.This means that when you visit different page types (such as article detail pages, category list pages, single pages, even the website homepage), the system will automatically judge the type of the current page and try to get the SEO title and description configured for the page itself first.

In particular:

  1. Content level priority:If you set SEO title and description for an article, a category or a single page in the backgroundindividuallythe system will use this content first.
  2. Content field extraction:If the content does not have a clear SEO description field or if you have not filled it in, the system will intelligently extract a portion of text from the "Summary" field (such as the "Document Summary" of the article, the "Category Summary" of the category) as the page Meta Description.
  3. Global settings fallback:If neither of the above two are able to obtain valid content, the system will fallback to the global title and description configured in the 'Homepage TDK settings'.

This mechanism ensures that whether or not you have performed fine-grained TDK configuration for each page, the website will have a reasonable and SEO-friendly title and description.

Core: Universal TDK Tag -{% tdk %}

The most convenient and recommended way to get the page SEO title and description in Anqi CMS template design is to use the universal {% tdk %}The tag is amazing because it can intelligently output the most suitable SEO information based on the context of the current page.

To get the SEO title of the current page, you can use it in the template's<head>area:

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

This code will automatically output the **title** of the page you are visiting.For example, if you visit the article detail page, it will output the SEO title (or article title) of the article;If the category list page is accessed, it will output the category's SEO title (or category name);If it is the homepage, it will output the title from the homepage TDK settings.

Similarly, getting the SEO description and keywords of the current page is also very simple:

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

Herename="Description"andname="Keywords"Parameters are used to indicate the label to retrieve the page description and keywords.

Flexible control of title display

{% tdk with name="Title" %}The label also provides additional parameters to allow you to control the title display more flexibly.

  • Attach website name:Many times, we want the page title to be displayed in search engines as "Page Title - Website Name" or "Page Title | Website Name". You can do this bysiteName=trueandsepParameter to implement:

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

    This page,<title>the tag content will automatically combine to form[当前页面标题] | [网站名称]such as "AnQi CMS template: Get SEO title and description | AnQi CMS official website".sepParameters are used to define delimiters, the default being-.

  • Display parent category title:In some category list pages or detail pages, you may want the title to include the name of its parent category, which can be achieved byshowParent=truethis parameter.

Deep customization: Directly obtain document/category/page SEO information

Although{% tdk %}The tag is already smart enough to meet most needs, but in some special cases, you may need to directly obtain the SEO field values of specific documents, categories, or single pages, rather than by{% tdk %}The result of intelligent label combination.

For example, if you want to display the SEO title of the document separately in a certain area of the document detail page, instead of using it as the page's<title>Label content, you can usearchiveDetailTags:

{% archiveDetail with name="SeoTitle" %}

Similarly, for the category page:

{% categoryDetail with name="SeoTitle" %}
{% categoryDetail with name="Description" %}
{% categoryDetail with name="Keywords" %}

For a single page:

{% pageDetail with name="SeoTitle" %}
{% pageDetail with name="Description" %}
{% pageDetail with name="Keywords" %}

These tags will directly output the corresponding SEO field values configured for the content type (document, category, single page) in the background. Generally speaking, we recommend using them first.{% tdk %}Standard to build page tags<title>and<meta>The tag, because it can better handle various page types and the fallback logic for content that has not been set.The direct way to obtain specific fields is more suitable for scenarios where it is necessary to display these original SEO data as part of the page content.

Actual operation steps

It is very direct to apply these tags to your website template:

  1. Locate the template file:Generally, the public header of the website (including<head>tags) is concentrated in a namedbase.htmlIn a template file with a similar name, located in the current topic of/templatedirectory.

  2. Find<head>Area:Find in this file,<head>to</head>the code block between.

  3. Insert TDK tags:In<head>In the area, replace or add the following code:

    `html &lt;!DOCTYPE html&gt;

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 页面SEO标题 -->
    <title>{% tdk with name="Title" siteName=true sep=" - " %}</title>
    <!-- 页面SEO关键词 -->
    <meta name="keywords" content="{% tdk with name="Keywords" %}">
    <!-- 页面SEO描述 -->
    <meta name="description" content="{% tdk with name="Description" %}">
    <!-- 其他head内容... -->
    

    <!-- 网站内容 -->
    

Related articles

How to set and optimize the static URL structure of a website to enhance the display effect in search engines?

The importance of website operation and URL structure is self-evident.A clear and meaningful URL not only helps users better understand the page content, but is also a key factor in search engine optimization (SEO).Especially for content management systems, properly setting up the pseudo-static URL structure can significantly improve the display effect and user experience of the website in search engines.AnQiCMS as a content management system that focuses on SEO optimization, provides strong and flexible support in this aspect.It not only built-in a variety of commonly used pseudo-static rules

2025-11-09

What device adaptation modes does AnQiCMS support to optimize content display?

With the popularization of mobile internet, the types of devices used by users to access websites are becoming increasingly diverse, ranging from large-screen PC monitors to compact smartphones. The display effect of website content is directly related to user experience and the effective transmission of information.AnQiCMS is well-versed in this field, providing a variety of device adaptation modes to help users flexibly optimize content display and ensure that the website presents a**status**on any device.The device adaptation strategy of AnQi CMS is mainly divided into three types, each mode has its unique implementation method and applicable scenario

2025-11-09

How to filter and display a list of specific content based on recommendation attributes (such as "Headline

When operating a website, we often need to highlight certain important or recommended content, such as placing the latest news at the "top" or marking popular products as "recommended".AnQiCMS provides a flexible recommendation feature that allows you to easily filter and display these specific contents, thereby better guiding users to browse and enhance the value of the content. ### Understanding Recommendation Attributes and Their Functions The recommendation attributes in AnQiCMS can be considered as a special tag for content, used to mark its importance and display method on the website.These properties are rich in variety, for example: *

2025-11-09

How to display thumbnails, titles, and summaries in the article list?

In website operation, how to display the content list efficiently and beautifully is the key to attracting users and increasing the number of visits.A clear display of a thumbnail, title, and introduction of an article list, not only can it help visitors find the content they are interested in at a glance, but it can also effectively improve the website's performance in search engines.AnQiCMS provides rich features and a flexible template system, allowing us to easily achieve such effects.How is the content of the article managed in the AnQiCMS backend?Display thumbnails, titles, and summaries in the article list

2025-11-09

How to implement the function of displaying and switching content in multiple languages?

Make your website go global: Anqi CMS multilingual content strategy and implementation In today's globalized digital age, many businesses and content creators hope that their websites can reach a wider audience.This means providing content display and switching functions in multiple languages to meet the reading habits of users in different countries and regions.AnQiCMS (AnQiCMS) is an efficient content management system that fully considers this requirement, providing a flexible solution to help you easily implement the multilingual function of the website.In AnQi CMS, implement multi-language display and switching of content

2025-11-09

How to display additional field data in the front-end template after customizing the content model?

AnQiCMS with its flexible content model function has brought great convenience to us in managing various types of website content.Whether it is an article, product, event, or any other content type that requires special fields, we can easily customize fields in the background to meet unique business needs.But when we eagerly create new fields in the background and fill them with data, new problems also arise: How can we accurately display these newly added custom field data on the front page of the website for visitors?Don't worry, AnQiCMS

2025-11-09

How to enable Markdown rendering and correctly display mathematical formulas and flowcharts in AnQiCMS?

In AnQiCMS, if you want to make your content more expressive, especially when it comes to displaying complex mathematical formulas or clear flowcharts, it is a very effective solution to flexibly use the Markdown editor.The new version of AnQiCMS has provided good support for this.Next, we will explore together how to enable these features in AnQiCMS, making your website content come alive.

2025-11-09

How to embed a comment list on the page and control its pagination display?

In website operation, user interaction is the key to enhancing site activity and content value.AnQiCMS provides a set of intuitive and powerful features that help us easily embed comment functions in pages and flexibly control the display of comment lists, especially its pagination management, which is crucial for pages with a large number of user comments. ### Enable comment functionality to bring content to life Firstly, we need to ensure that the comment functionality is enabled on the backend so that users can post comments.Once the comment feature is activated

2025-11-09