In website operation, the TDK (Title, Description, Keywords) information of the website plays a crucial role.They are not only the key for search engines to understand the content of the page, but also the important basis for users to decide whether to click on your website in the search results.A well-optimized TDK can significantly improve a website's ranking in search engines and attract more target users.AnQiCMS (AnQiCMS) is a content management system born for SEO optimization, naturally providing strong and flexible support for TDK management.

AnQiCMS integrates TDK configuration into every corner of the website, whether it is the homepage, specific articles, product, category pages, or even individual single pages and Tag pages, you can find the corresponding setting entry.For example, you can find the 'Home TDK settings' in the 'Background Settings', which is specifically used to define the title, keywords, and description of the website homepage.When you edit specific content, whether it is the 'Add Document' module's 'SEO Title', 'Document Keywords', 'Document Summary', or the 'Document Classification', 'Document Tags', 'Page Management' modules, all provide independent TDK configuration items to ensure that each page can have customized TDK information.

To dynamically display these TDK information in the AnQiCMS template, the key is to flexibly use its built-in "万能TDK tag"-tdk. This tag's strength lies in its ability to intelligently capture and output the corresponding TDK content based on the type of the current page (whether it is the homepage, article page, category page, or others), which greatly simplifies the development of templates.

Let's see how to use this in the templatetdkTag to display TDK information:

Flexible display of page title (Title)

The page title is usually<title>The content of the tag has the greatest impact on SEO. UsetdkThe tag retrieves the page title very directly.

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

In practical applications, we may want to automatically add the website name after the page title or a custom delimiter.tdkThe tag provides additional parameters for this.

  • Append website name suffix: If you want to automatically append the website name configured in "Global Settings" to the page title, you can usesiteName=true.
    
    <title>{% tdk with name="Title" siteName=true %}</title>
    
  • Custom delimiter: By default, a hyphen will be used between the website name and the page title-Comma, you can change it throughsepparameters.
    
    <title>{% tdk with name="Title" siteName=true sep="_" %}</title>
    
  • Display parent category title: Sometimes, on the article or category page, it is necessary to display the title of the parent category it belongs to, you can useshowParent=trueto achieve.
    
    <title>{% tdk with name="Title" showParent=true %}</title>
    
    By combining these parameters, you can precisely control the display format of the page title according to your actual needs.

Output page keywords (Keywords)

Page keywords (Keywords) are usually set through<meta name="keywords" content="...">tags. Although modern search engines have reduced their weight, they still have value as auxiliary information.

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

If you wish to store the retrieved keywords in a variable for further processing, you can also do it this way:

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

Display page description (Description)

Page description (Description) is a summary below the title in search engine results, which directly affects the desire of users to click.tdkTags can easily obtain the page description.

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

Similarly, it can also be stored in a variable:

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

Add the canonical link (CanonicalUrl)

The canonical link (CanonicalUrl) is used to tell search engines which is the preferred version of the page, to avoid duplicate content issues.In AnQiCMS, you can set standard links for pages while editing content in the background.In the template, we should check if there is a standard link, and only output it when it is set.

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

This has been used{%- ... -%}To remove the blank lines around the tag, making the output HTML cleaner.if canonicalThe judgment ensures that only when the page background is configured with a standard link,linkthe tag will be rendered to the HTML.

where should the TDK tag be placed?

In most cases, these TDK-related<title>and<meta>tags should be placed in the website template's<head>Within an area. In the AnQiCMS template structure, this means they are most commonly added to the public header files, such astemplate/您的模板目录/partial/header.htmlortemplate/您的模板目录/bash.htmlThrough this method, all pages that inherit or reference these public files can automatically have the correct TDK information, without the need to rewrite it on each individual page template.

Summarize and practical suggestions

Proper configuration and use of TDK information is the foundation of website SEO optimization. AnQiCMS'stdkTags make this process efficient and intelligent. In content operation, it is recommended that you:

  1. Configure TDK for each pageEnsure that all important pages have unique, precise titles, keywords, and descriptions.
  2. Title is precise and attractiveThe title should include core keywords and be able to attract user clicks.
  3. Concise description: The description should summarize the page content, include relevant keywords, and encourage users to visit.
  4. Do not stack related keywordsKeywords should be highly relevant to the page content and avoid overloading.
  5. Make good use of standard links.: Especially when your website has pages with similar content or accessible through different URLs, it is necessary to set up standard links.

By using the above method, you can fully utilize the TDK management capabilities of AnQiCMS to achieve better search engine performance for your website.


Frequently Asked Questions (FAQ)

Q1: Why did the SEO title I set in the background not show completely in the browser tab?A1: AnQiCMS'tdkThe default behavior when obtaining the page title may be affected bysiteNameandshowParentthe parameters. For example, if the template uses{% tdk with name="Title" siteName=true %}Then even if you only set the article title, the website name will be automatically appended to the title displayed by the browser. Please check the template code you are using.tdklabel'ssiteNameandshowParentDoes the parameter meet your expectations, or you can directly enter the complete title containing the website name when editing articles in the background.

Q2:tdkWhere does the "versatile" nature of the tag manifest? How does it know the TDK information of the current page?A2:tdkThe versatility of the tag lies in its ability to intelligently recognize the current page type.When you visit the homepage, it will go to get the content from the "Homepage TDK settings";When you visit the article detail page, it will automatically retrieve the SEO title, keywords, and description set for the article in the background;Similarly, when accessing category pages, single pages, or Tag pages, it will automatically associate and extract the TDK information configured in the corresponding module.Developers do not need to write different TDK acquisition logic for different types of pages, which greatly improves the reusability and development efficiency of templates.

Q3: Why is it added in the template?CanonicalUrlWhen,{%- if canonical %}such a judgment?CanonicalUrlWhat is its role?A3:CanonicalUrlThe (standard link) is a very important SEO element, it is used to inform search engines of the 'authoritative' version of a page.When website content can be accessed through multiple URLs (for example, the same article exists with and without parameters, or duplicate content in different categories), search engines may find it difficult to determine which version is the preferred one, thereby potentially dispersing the page ranking weight.Setting standard links can concentrate these weights, enhancing SEO effect. In the template.{%- if canonical %}The judgment is to ensure that only when the background has indeed set the standard link for the current page, will it output in the page HTML<link rel="canonical" ...>Label. This can avoid outputting empty or unnecessary standard links, maintaining the cleanliness and standardization of HTML.