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:
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).
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 can
siteName=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}}" />