In the field of website operation and search engine optimization (SEO), Canonical (standard) links are a very important concept.It can help search engines identify and handle duplicate content issues on websites, ensuring that the authority and ranking of the site are not affected by scattered content.In AnQiCMS (AnQi CMS), implementing the display of canonical links is a key step in optimizing website SEO, and through its flexible template system, this process becomes intuitive and efficient.
The main role of canonical links is to inform search engines which page is the preferred and most authoritative version when there are multiple pages with similar or identical content.This not only solves the problem of duplicate content caused by URL parameters, pagination, print versions, or other website structures, but also effectively integrates the weight of all these duplicate pages and focuses it on the standard page you specify.If the correct Canonical settings are lacking, search engines may find it difficult to determine which page is the 'original', which may lead to the dispersion of page authority and even the demotion of your content.
https://www.example.com/article/98Instead of a relative path. This setting ensures that you can precisely control the normalization behavior of each page.
We need to take advantage of its powerful template tag system to display Canonical links in the AnQiCMS template.AnQiCMS uses a syntax similar to the Django template engine, calling back-end data through specific tags.tdk.
Typically, the canonical link should be placed on the page.<head>Within the area. If you are using the AnQiCMS default template or following its template design conventions, you will have a common header file (for examplepartial/header.htmlorbash.html),All pages will refer to it. You can conveniently add the Canonical link code in this file.
Here is the code snippet for implementing Canonical link display:
{%- tdk canonical with name="CanonicalUrl" %}
{%- if canonical %}
<link rel="canonical" href="{{canonical}}" />
{%- endif %}
Let's parse this code:
{%- tdk canonical with name="CanonicalUrl" %}This line of code is used:tdkLabel to get the Canonical URL of the current page.tdkIs AnQiCMS used to obtain the page TDK (Title, Description, Keywords) and standard link general tag.canonicalIt is a variable name defined for the Canonical URL value obtained, you can name it freely.with name="CanonicalUrl"Specified is the value of the field named 'CanonicalUrl', which corresponds to the 'Standard Link' field filled in the background document editing interface.{%-and-%}The symbol is used to remove the whitespace characters of the line containing the tag, to keep the template output neat.
{%- if canonical %}and{%- endif %}: This is a conditional judgment statement. It checkscanonicalif the variable has a value.- The reason for this judgment is that not all pages need to manually set a specific Canonical link. If a page does not explicitly set the "standard link" in the background, then
tdkThe label may not return any value. - Only when
canonicalWe only want to output on the page when the variable indeed contains a URL.<link rel="canonical">Labels, avoid outputting empty or invalid labels, this is a good practice.
- The reason for this judgment is that not all pages need to manually set a specific Canonical link. If a page does not explicitly set the "standard link" in the background, then
<link rel="canonical" href="{{canonical}}" />: This is the standard HTML tag used to declare the specification URL of the page.rel="canonical"Tell the search engine that this link is a canonical link.href="{{canonical}}"Embed the Canonical URL value we retrieve from the backend intohrefthe attribute.
Place this code in your template.<head>Inside the tag, AnQiCMS will automatically display the Canonical link correctly according to the settings in the background.
Implementing canonical link display correctly is crucial for your website's SEO.It can not only avoid search engine penalties caused by duplicate content, but also help the target keyword ranking become more stable and strong.Combine with other advanced SEO tools provided by AnQiCMS, such as Sitemap generation, 301 redirect management, and keyword libraries, you can build a highly search engine friendly website and stand out in the fierce online competition.
Frequently Asked Questions (FAQ)
What is the difference between canonical links and 301 redirects, and which one should I choose?Canonical links and 301 redirects are both methods of handling duplicate content, but they are used in different scenarios. A 301 redirect ispermanentA page redirect, it tells the search engine that a page has been permanently moved to a new URL and passes all the weight of the old page to the new page.The old page will no longer be indexed.PreferredVersion, the search engine will prioritize indexing this preferred version and aggregate its weight.
- Choose 301 redirect:When you want to completely remove the old page and redirect both users and search engines to the new page. For example, the page URL structure has changed permanently.
- Select the Canonical link:When you need to keep multiple similar pages for some reason (such as different color versions of products, URLs with tracking parameters, print-friendly pages), but do not want them to compete for rankings.
What will happen if I haven't set the Canonical link in the AnQiCMS backend?If you have not manually set the 'standard link' for a page in the AnQiCMS backend, and the template already includes what we mentioned
{%- if canonical %}then the page will not output<link rel="canonical">Label.This means that the search engine will automatically determine the standard version of the page.In some cases, search engines may make the correct judgment, but if your page has multiple URL access methods (such as parameterized URLs, coexistence of HTTP and HTTPS versions, and WWW and non-WWW versions), search engines may treat these as different pages, resulting in content duplication and dispersing the ranking weight of the page.link rel="canonical"Tags to clearly inform search engines.Can canonical links point to pages on different domains?Can.Canonical links theoretically can point to pages on different domains.This is especially useful when publishing content across domain names or for joint promotion.For example, you published an article on AnQiCMS and also released the same content on another cooperative website.To avoid duplicate content issues, you can set a Canonical link on the article page of the cooperative website, pointing to the original article on your AnQiCMS website.This will inform the search engine that the version of your AnQiCMS website is original and authoritative.But please make sure that you truly own or control these two websites, and that this setup is well-considered to avoid misleading search engines or causing unnecessary SEO issues.