As an expert deeply familiar with website operation, I know the importance of SEO titles, keywords, and descriptions (usually referred to as TDK, Title, Description, Keywords) for a website to perform well in search engines.They are the information that users first see on the search results page, directly affecting the click-through rate, and are also a key signal for search engines to understand the content of the page.In AnQiCMS (AnQi CMS), obtaining and applying these key SEO information becomes intuitive and efficient due to its powerful and flexible template system and backend configuration features.

Today, let's delve into how to accurately obtain the SEO title, keywords, and description of the current document in AnQiCMS, and巧妙ly apply them to the page Meta tags to win more exposure for your website.


AnQiCMS SEO实战:How to accurately obtain and apply page Meta tag information?

In today's fiercely competitive digital environment, every website operator aspires for their content to stand out in search engines.And the Meta tags on the page - especially the SEO title, keywords, and description - are the "business card" we show to search engines and potential users to present the essence of the content.AnQiCMS is a system designed for SEO-friendliness, providing us with a simple and efficient way to manage and deploy these crucial information.

I. How does AnQiCMS manage document SEO information?

AnQiCMS manages SEO information deeply at all levels of content publication, ensuring that you can finely control every bit of content:

  1. Document (article/product) level:This is the most direct, finest-grained control point. When you are writing or editing any onearticle or productAt the "Other ParametersThe TDK entered here will be directly applied to the detail page of this document, with the highest priority.
  2. Category level:in managementDocument CategoryAt the same time, you can also set the 'SEO title', 'keywords', and 'category description' for each category.This information will be applied to the list page of the category.If a document under a category does not have a TDK set individually, the system may trace up and use the TDK of its category as the default value.
  3. Single page level:For "About Ussingle pageSimilarly, the page management interface provides settings options for "SEO Title
  4. Global (Home) Level:Under the "Backend Settings" and "Home TDK Settings", you can set for the entire website,HomeDefine TDK.This usually serves as the final fallback for all pages, that is, if no specific page or category has set TDK, the system will try to use the global TDK of the website or intelligently extract it from the page content.

This hierarchical design ensures the flexibility and coverage of SEO information, allowing you to strategically deploy according to the importance of content and business needs.

Part two: UsingtdkLabel to get SEO information

AnQiCMS's template system uses syntax similar to Django, through powerful built-in tags, you can easily call various data configured in the background on the front-end page. For page Meta information, AnQiCMS provides a 'universal'tdkA tag that can intelligently identify the current page type (whether it is document details, category list, single page, or home page), and automatically extract the most matching SEO data.

Let's see how to use it:

1. Get the page title (Title)

Page's<title>Tags are the most important part of SEO. UsetdkTags to get the SEO title of the current page is very direct:

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

This tag automatically retrieves the **SEO title of the current page. It also provides some very useful parameters to further customize:

  • siteName=true: Will automatically append the website name at the end of the title, for example, 'Article Title - Your Website Name.'
  • sep=" - ": Can customize the separator when appending the website name, default is a hyphen.
  • showParent=trueIn some cases (such as the category page), the title of the parent category can be displayed.

Example code:

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

2. Get the page keywords (Keywords)

KeywordsTags may have decreased in weight in modern SEO, but they are still an effective way to provide search engines with a page content topic hint:

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

tdkThe tag automatically extracts keywords from the current page, category, or global settings and outputs them in the form of a comma-separated list.

3. Get page description (Description)

Page description (Meta Description) is the content summary that users see in search results, an attractive description can significantly increase click-through rate:

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

tdkThe tag will intelligently retrieve the page's Meta Description.If the document or category does not have a description set explicitly, the system will usually extract a paragraph from the document summary or main content as the default description.

4. Obtain the specification link (CanonicalUrl)

CanonicalUrlIt is an advanced SEO tool used to resolve content duplication issues, informing search engines which is the 'authoritative' version of the content:

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

Here we first need toCanonicalUrlAssign a value to a variable namedcanonicalThen check if it exists. Only when the specification link exists will we output this on the page<link>Label, this is a strict and recommended practice.

III. Practical Application: Deploy SEO information to the page Meta tag

In order for these SEO information to truly take effect, we need to place them in the website template's<head>area. In AnQiCMS, it is usually recommended to place the general layout files of the website (such astemplateUnder the directorybash.htmlorbase.htmlConfigure in the bracket. This way, all pages inheriting the layout can automatically have the correct Meta tags.

Here is a typical HTML<head>area, integrating the abovetdkLabel example:

`html &lt;!DOCTYPE html&gt;

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

{# 页面标题,附加网站名称作为后缀 #}
<title>{% tdk with name="Title" siteName=true sep=" - " %}</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}}" />
{%- endif %}

{# 引入CSS文件等其他头部资源 #}
<link href="{% system with name="TemplateUrl" %}/css/style.css" rel="stylesheet">
{# 您可能还需要引入多语言切换的hreflang标签 #}
{%- languages websites %}
{%- for item in websites %}
<link rel="alternate" href="{{item.Link}}" hreflang="{{item.Language}}">
{%- endfor %}
{%- endLanguages %}

{# 其他SEO相关的Meta标签,例如Open Graph, Twitter Cards等,可根据需求自行添加 #}