What is the correct way to call `CanonicalUrl` in the `tdk` tag of AnQi CMS?

Calendar 👁️ 77

As an experienced website operations expert, I am well aware of the crucial role of Search Engine Optimization (SEO) in the success of a website, and one of the frequently overlooked yet crucial details isCanonical UrlThe correct use. In a powerful content management system like AnQiCMS, we also need to master itstdkTag callCanonicalUrlThe practice of ensuring the uniqueness and authority of website content, thereby achieving better performance in search engines.

What is Canonical URL and why is it so important?

Before we delve into the specific usage of AnQi CMS, it is necessary to understandCanonical UrlThe essence of a normalized URL. Simply put,Canonical UrlIt is an HTML tag<link rel="canonical" href="[URL]"/>and it is placed on the web page's<head>The area is used to tell the search engine: "Although this page can be accessed through multiple URLs or is highly similar to the content of other pages on the website, please concentrate the weight and indexing on the specific canonical URL I specify."

Imagine that your website may have multiple URLs pointing to the same or similar content: for example, the same product page with different tracking parameters (example.com/product?ref=1andexample.com/product?source=ad)、the URL of the same article in different categories(example.com/category1/articleandexample.com/category2/articleOr if your website content is republished on other platforms, search engines may consider it duplicate content.If the search engine cannot determine which is the "official" or "preferred

Canonical UrlThe appearance is to solve this problem.It acts as a clear signpost, explicitly telling search engines which URL is the authoritative version of the content, thereby helping us to consolidate scattered SEO weight, avoid unnecessary duplicate content penalties, and ensure that search engines can correctly index the pages we want to display to users.

Configuration entry for Canonical URL in AnQi CMS

Set in AnQi CMS,CanonicalUrlThe process is intuitive and close to the content management logic.As the core of content management, Anqi CMS allows us to configure the standardized links for each specific document (including articles, products, etc.)When you create or edit an article, a product detail page, or any other document that requires independent SEO management in the background, you will find an input box named "Standard Link" in the "Other Parameters" section of the editing interface.

The document clearly states: "If you want to direct the current document to another page, you need to fill in here.The standard link needs to be called using the canonical tag in the template.This tag may be used on foreign trade websites.https://www.kandaoni.com/article/98.This means that you need to manually fill in this field only when you want the 'main version' of the current page to be different from its own URL.This usually occurs when content is syndicated, or there are indeed multiple URLs pointing to the same content within a website, and you want to explicitly specify a preferred URL scenario.

tdkLabel: The万能钥匙of page SEO

Anqi CMS provides powerful for website front-end templatestdkLabel, it is the all-purpose key for managing page Title, Keywords, Description, and other core SEO elements.The essence of this tag lies in its 'universal' word— it can intelligently extract and output the corresponding TDK information according to the type of the current page (home page, category page, document detail page, etc).CanonicalUrlAs an important part of page SEO, it can also be achieved through thistdkCall the tag.

On the level of template design, we use{% tdk 变量名称 with name="字段名称" %}such syntax to obtain the required information. ForCanonicalUrl, we just need to specifynameparameters for"CanonicalUrl"Just do it.

InvokeCanonicalUrlthe correct posture: template code practice

MasteredCanonicalUrlThe configuration location andtdkAfter the basic usage of the tag, the next is how to call it elegantly and correctly in the front-end template. The most critical principle is:Only when the background is explicitly set for the current pageCanonicalUrlit will be output to the HTML.Avoid outputting empty or unnecessary contentCanonicalUrlTags, which help keep HTML code neat, and avoid ambiguity for search engines.

The following is a call toCanonicalUrlrecommended code practices, usually placed in your website template.<head>Area:

{# 首先,尝试从tdk标签获取CanonicalUrl的值,并将其赋值给名为`canonical`的变量 #}
{%- tdk canonical with name="CanonicalUrl" %}

{# 接着,我们判断这个`canonical`变量是否存在且不为空 #}
{%- if canonical %}
    {# 如果存在且不为空,则输出link标签,rel属性为"canonical",href属性为获取到的CanonicalUrl #}
    <link rel="canonical" href="{{canonical}}" />
{%- endif %}

The advantage of this code lies in its robustness:

  1. {%- tdk canonical with name="CanonicalUrl" %}This line of code will attempt to retrieve the TDK settings from the current page.CanonicalUrlThe value. If the 'standard link' field is set during the background document editing, it will be assigned tocanonicalthis variable; if not set,canonicalthe variable will be empty.
  2. {%- if canonical %}This is a conditional judgment statement, it will checkcanonicalwhether the variable contains valid content. Only whenCanonicalUrlit is explicitly set and a non-empty value is obtained in the background, the code block inside it will be executed.
  3. <link rel="canonical" href="{{canonical}}" />: If the condition is met, this line of code will generate standardCanonical Urltags and use{{canonical}}to output the actual normalized link.

In this way, we ensureCanonicalUrlTags are only displayed when necessary, avoiding the output of invalid tags and maintaining the cleanliness of the page and the accuracy of SEO strategy.

In-depth analysis and practical application scenarios

In actual operation,CanonicalUrlNot applicable to all pages, but a SEO tool for specific scenarios.

  • Content aggregation and distribution:For example, if you have an original article and you want to publish it on multiple cooperative media platforms. To ensure that search engines know that your website is the 'source', you can include on all转载 pages (including different URL versions that may exist on your own website), thatCanonicalUrlPoint to the original article link on your website.
  • E-commerce product SKU page:Many e-commerce websites will

Related articles

How to use the `showParent=true` attribute in AnQi CMS to display more hierarchical information in the Title?

AnQi CMS, as an enterprise-level content management system that deeply understands the way of content operation, its powerful functional design reflects a profound understanding of user needs and search engine optimization.The importance of page title (Title) in website operation is self-evident, it is not only the first entry point for users to click, but also the core basis for search engines to judge the relevance of page content.Today, let's delve into how AnQi CMS cleverly utilizes the `tdk` tag's `showParent=true` attribute to give the page title more rich and hierarchical information

2025-11-07

How to customize the separator of the `sep` attribute for the AnQi CMS page title?

In today's digital world, every detail of a website can affect its performance in search engines and the first impression of users.The page title (Title) serves as the 'face' of the website content, its importance is self-evident.It is not only a key clue for search engines to understand the theme of a web page, but also a direct factor for users to decide whether to click in the search results.AnQiCMS (AnQiCMS) knows this and is committed to providing users with efficient and customizable content management solutions, including fine-grained control over page titles.As an experienced website operations expert

2025-11-07

What is the difference between `siteName=true` and `siteName=false` in the Title tag of AnQi CMS?

The secret of the Title tag in AnQi CMS: Deep analysis of `siteName=true` and `siteName=false`The title tag acts as the 'face' of a webpage, its importance is self-evident.It is not only a key signal for search engines to understand the theme of a page, but also the primary information that users determine at a glance in search results.

2025-11-07

What parameters should be noted when using the `tdk` tag of AnQi CMS?

As an experienced website operations expert, I know that TDK (Title, Description, Keywords) are crucial for the performance of a website in search engines.AnQi CMS provides us with powerful and flexible TDK management capabilities with its SEO-friendly design philosophy.Today, let's delve into the various parameters that need to be paid attention to when using the `tdk` tag in Anqi CMS, to help everyone better master this core SEO element.

2025-11-07

What is the role of the variable name of the `tdk` tag in the AnQi CMS template?

## The `tdk` tag in Anqi CMS template: The key to mastering SEO and building high-performance websites As an experienced website operations expert, I deeply understand the core status of TDK (Title, Description, Keywords) in website SEO.They are not only key signals for search engines to understand web content, but also the first line of defense to attract users and increase website traffic.In daily content operations, how to efficiently and flexibly manage TDK is an important factor in enhancing website competitiveness. Today

2025-11-07

How can AnQi CMS automatically generate Sitemap to help search engines crawl TDK information?

In today's highly competitive online environment, it is the goal of every website operator to efficiently have their website content discovered, crawled, and accurately displayed by search engines.Among these, the TDK (Title, Description, Keywords) information of the website, is like the "business card" of your website presented on the search engine results page (SERP), and its quality directly affects the click-through rate and user access.However, how can we ensure that these carefully prepared TDK information can be effectively read by search engine spiders and presented to users?AnQi CMS knows this pain point

2025-11-07

How does the Robots.txt configuration of Anqi CMS affect the crawling of TDK tags by search engines?

As an experienced website operations expert, I am well aware of the importance of Search Engine Optimization (SEO) for website visibility.Among many SEO strategies, the title (Title), description (Description), and keywords (Keywords) of a web page, which we usually call TDK tags, are the core elements that attract the attention of search engines and users.And the Robots.txt file, this seemingly simple text file, acts like a director behind the scenes, subtly influencing how search engine spiders interact with our website content, including TDK tags.

2025-11-07

How to accelerate the inclusion of TDK tags through the link push function of AnQi CMS?

As an experienced website operations expert, I am well aware that in today's highly competitive digital environment, how to make the website content stand out and be quickly discovered and indexed by search engines is the focus of every operator.TDK tags (Title, Description, Keywords) act as the "business card" of website content, and their quality and inclusion speed directly affect the website's search visibility and click-through rate.

2025-11-07