In website operation, we all hope that our content can be accurately understood and efficiently indexed by search engines.Among them, Canonical URL (规范链接) is a very important concept.It can help us solve the problem of duplicate content that may arise due to content similarity or availability from multiple URLs, clearly telling search engines which is the 'main version' of the content, thus concentrating the page ranking weight and avoiding dispersion.
AutoCMS is an efficient and flexible content management system that fully considers the needs of SEO optimization, built-in powerful TDK (Title, Description, Keywords) management functions, which include support for standard links. Next, let's take a look at how to appropriately use the templates in AutoCMS.tdkLabel to display the specification link of the current page.
Understanding Canonical URL and Its Importance
Imagine you have an article that may have multiple links on the website for the following reasons:
- Accessed through different classification paths:
/news/article-1and/featured/article-1 - With parameters in the URL:
/article-1?source=baiduand/article-1?source=google - Even if the same or highly similar content is published on your other sister sites.
These different URLs, in the eyes of search engines, may point to "different" pages, but in fact, they display the same content.If you do not give clear instructions to the search engine, it may be "confused", not knowing which version is the most important and should be prioritized, which may dilute your ranking weight.
The role of Canonical URL is like sticking a 'official specification' label on these similar content pages. By placing a<head>in the area<link rel="canonical" href="[规范链接]" />Tags, you can tell the search engine: "Hey, although this page can be accessed from this current URL, its main, authoritative version is here!"}]
In the Auto CMS backend, set the specification link
The Auto CMS provides detailed control in content management. When you publish or edit documents, you can set the standard link for each page individually in the background.
Specifically, in the backend management interface of Anqi CMS, whether you are creating new articles, products, or editing existing documents, you will find a name called “Other parametersThe folded area. After expanding this area, there is a field called “Standard link.
When publishing documents (or editing):
- Enter "Content Management" -u003e "Publish Document" (or edit an existing document).
- Fill in or modify the document content.
- Scroll the page to find "Other parameters and click to expand.
- In “Standard linkInput box, enter the authoritative URL you want for this page. This link should be a complete, absolute link starting with
http://orhttps://https://www.yourdomain.com/article/your-unique-slug.
When is it necessary to fill in this field?When the content of a page on your website is highly repetitive of the content on another page, and you want search engines to index and rank only one specific version, you need to manually fill in the specification link here.If left blank, in most cases, the current URL of the page will be considered as its own canonical link.
Display Canonical URL in the template
Set the background content, and the next step is to correctly display this specification link in the website's frontend template. The Anqi CMS provides powerful template tag features, wheretdk标签就是我们用来处理页面TDK信息(包括规范链接)的“万能”工具。
tdk标签的使用方式非常灵活,我们可以通过它的nameThe parameter is used to specify the specific information to be obtained. For specification links, we use thenameisCanonicalUrl.
recommended template code style:
You should put it in your template file (for exampledetail.html,index.html,or public header filebash.html) of<head>within the region, add the following code:
{# 获取页面的规范链接,并将其赋值给名为 'canonical' 的变量 #}
{%- tdk canonical with name="CanonicalUrl" %}
{# 判断 'canonical' 变量是否存在且有值,如果存在,则输出规范链接标签 #}
{%- if canonical %}
<link rel="canonical" href="{{canonical}}" />
{%- endif %}
Code Explanation:
{%- tdk canonical with name="CanonicalUrl" %}: This line of code will call the Anqi CMS.tdkTags, throughname="CanonicalUrl"Specify the specification link of the current page. The value obtained will be assigned to a variable namedcanonical. It should be noted that the tags before and after the{%-It is to suppress the output of unnecessary blank lines, making the generated HTML code cleaner.{%- if canonical %}This is a conditional judgment, which checkscanonicalVariable has an actual value. If there is no specification link set for the current page or it is set to empty,canonicalthe variable will be empty and no output will be generated.<link rel="canonical" ... />Label. This is a good practice to avoid empty or unnecessary tags in HTML.<link rel="canonical" href="{{canonical}}" />IfcanonicalVariable has a value, this line of code will be rendered, and the specification link should be added correctly to the page.<head>area.
Where to put the code?
This code snippet should usually be placed in your website template.<head>标签内。一个常见的位置是在你网站的公共头部文件(如 Englishpartial/header.htmlorbash.htmlIf your template uses this structure),all pages that inherit or include this header file will automatically apply the specification link settings.
Summary
Through the backend management interface and flexible template tags provided by Anqi CMS, you can easily set and apply standard links to your website pages.Correct use of Canonical URL not only helps you solve SEO problems caused by duplicate content, but also effectively concentrates page authority, thus improving the overall performance of the website in search engines.
Common Questions and Answers (FAQ)
1. Why use in the templatetdkIt is recommended to add when displaying the Canonical URL with{% if canonical %}such a conditional judgment?This is to ensure that the generated HTML code is more standardized and neat. If there is no clear specification link set for a certain page by the backend,{% tdk canonical with name="CanonicalUrl" %}It will return an empty value. If there is no judgment at this time and output directly<link rel="canonical" href="" />, an empty one will be produced.hrefProperty label.Although this usually does not cause serious errors, from the perspective of code quality and search engine parsing, it is better to only output this tag when the standard link has an actual value.
2. If I do not set a 'standard link' for a page in the backgroundtdkWhat will the tag return? Will this page have a Canonical URL?If you haven't explicitly set the 'Canonical URL' in the background,tdktag in retrievingCanonicalUrlIt will usually return an empty value. In this case, the page front-end will not display<link rel="canonical" ... />Label.通常,搜索引擎会默认将该页面的当前URL视为其自身的规范URL。But please note that if there are multiple accessible URLs or highly similar content on the page, and you wish to specify an authoritative version, manually setting the standard link is essential.
3. Canonical URL is only applicable to article or product detail pages? Can I use it on category pages, tag pages, or single pages?
tdkThe label is "Universal TDK Tag{% tdk canonical with name="CanonicalUrl" %}Get and display the specification links for these pages.However, according to the document description of Anqi CMS, the setting of 'standard link' is mainly mentioned in the 'publish document' module.For other types of pages, if the backend does not provide this setting, you need to consider, based on the actual situation and SEO requirements, whether you need to manually construct logic in the template to generate standard links, or confirm whether the default URLs of these pages are sufficient to meet the standardization requirements.