It is crucial to ensure that search engines efficiently and accurately crawl and understand our content in website operation.Amongst them, the canonical URL is an essential SEO strategy.It can help us solve the problem of duplicate content, concentrate the page weight, thus optimizing the website's performance in search engines.AnQiCMS as a SEO-friendly and powerful content management system naturally also provides comprehensive link configuration options, allowing users to easily manage this important feature.

What is a canonical URL and its importance?

Imagine that an article on your website may have multiple URLs for various reasons.For example, the same product detail page may be accessed through different category paths, or parameters may be added to the end of the URL due to reasons such as advertising投放, statistical tracking, etc.Or perhaps, your website also supportswwwandnon-wwwDomain names, even when they havehttpandhttpsVersion. In these cases, although the content is the same, they are considered different pages by search engines.

For search engines, these different-looking URLs point to content that is completely the same or highly similar.This would cause what is called the 'duplicate content' problem. When search engines find a large amount of duplicate content, they may become confused, not knowing which page is the original or preferred, which not only disperses the page weight, affects the crawling efficiency (wasting crawling budget), but may also lead to poor page ranking or even punishment.

The canonical URL is the URL that tells search engines which one is the preferred URL to be indexed and ranked among many URLs pointing to the same content. By placing in the HTML of the page<head>partly add a specific<link rel="canonical" href="..." />Label, you can explicitly indicate to the search engine which URL represents the 'standard' version of the content.This helps to avoid duplicate content penalties, consolidate page authority, and ensure that both users and search engines can find the version you want them to find.

Configuration of Canonical URL in AnQiCMS: step by step implementation

Configuring the specification link in AnQiCMS is very intuitive, mainly performed in the backend interface while creating or editing specific content (such as articles, products, etc.).

First, you need to log in to the AnQiCMS backend and navigate to the 'Content Management' section.Whether it is to "publish documents" to create new content or to edit existing content through "document management", you can find the settings options for standard links on the content editing page.

At the bottom of the document editing page, there is usually a collapsible area named "Other Parameters".After expanding this area, you will find a dedicated input box for entering the 'standard link'.Enter the full, preferred URL for this content here.Make sure to usehttp://orhttps://Absolute path at the beginning, for examplehttps://www.yourdomain.com/docs/anqicms-guide.

This feature is particularly suitable for the following scenarios:

  • Duplicate content across domains or subdomains:If your same article is published on the main site and the sub-site, you can specify one of them as the standard version.
  • Multi-path access to the same content within the site:For example, a product page may be accessed through/products/categoryA/product-nameand/new-arrivals/product-nameCan be accessed, you should choose one as the standard URL.
  • URL with tracking parameters: yourdomain.com/pageandyourdomain.com/page?source=adsContent is the same, the URL without parameters should be set as the standard.
  • Different versions with similar content:For example, if the print version or mobile version of a product is highly similar in content, the main page can be set as the standard.

Fill in this input box correctly, and you will have completed the background configuration.

Display the Canonical URL in the template: Ensure search engines recognize it.

It is not enough to fill in the specification link only in the background. When search engines crawl web pages, they need to go through the code in the page.<link rel="canonical" href="..." />Tags to identify the specific specification URL. This means that you need to dynamically output the specification link configured in the AnQiCMS template file to the page.<head>Section.

AnQiCMS provides a convenient TDK (Title, Description, Keywords) tag to help us achieve this, including standard linksCanonicalUrlthe call.

You need to find your website template file, which is usually located in/templateUnder the directorybase.htmlor a similar public header template file. In the file's<head>Tag inside, you can add the following code to get and display the specification link:

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

Let's interpret this piece of code:

  • {%- tdk canonical with name="CanonicalUrl" %}This line of code is an AnQiCMS template tag, its function is to obtain the standard link value of the current page from the background.canonicalis the temporary variable name we define for this value,name="CanonicalUrl"This indicates that we want to retrieve the data of the standard link. The preceding-symbol is to avoid extra blank lines in the output, making the HTML code cleaner.
  • {%- if canonical %}This is a conditional judgment. It checks the one we just got.canonicalWhether the variable contains the actual URL value (i.e., not empty). Only when the backend has indeed configured the standard link for the current page, will the internal code block be executed.
  • <link rel="canonical" href="{{canonical}}" />If:canonicalThe variable has a value, and this line of HTML code will be output to the page.rel="canonical"Clearly tells the search engine that this is a standard link, whilehref="{{canonical}}"the preferred URL set in the background was inserted.
  • {%- endif %}: End condition judgment.

The advantage of this code is its flexibility: it will only output when you actually specify a standard link for a page, avoiding unnecessary code or incorrect empty tags. At the same time, placing it in<head>Tagged within, it is the recommended practice by the search engine to ensure that crawling tools can find and process standard link information in the first time.

Through AnQiCMS flexible backend configuration and powerful template tags, you can easily set standard links for website content.This not only effectively solves the SEO problems caused by duplicate content, but also helps search engines more efficiently crawl your website, concentrate page authority, and ultimately improve the performance of your website in search results.


Frequently Asked Questions (FAQ)

Q1: If I have not set a 'standard link' for a document in the background, how will the system handle it in the template?

A1: If you have not set a specification link for a specific document in the background,{%- tdk canonical with name="CanonicalUrl" %}This line of code retrievescanonicalThe variable will be empty. Since the template uses{%- if canonical %}for conditional judgment, whencanonicalis empty,<link rel="canonical" href="..." />The tag will not be output to the HTML code of the page.This page will not have an explicit specification link declaration, search engines will judge the specification version of the page according to their own algorithms.

Q2: Can I directly use the URL of the website homepage as the standard link for all pages?

A2: No. The purpose of the standard link is to indicatethe same contentThe preferred URL. If all the page canonical links point to the home page, it will seriously mislead search engines.Search engines will consider all the content on your website to be duplicate of the homepage, which will not only seriously affect the inclusion and ranking of other pages, but may even lead to a drop in the ranking of the entire website.Each independent content page should have its own unique, canonical link pointing to the preferred version of the content.

Q3: What is the difference between Canonical URL and 301 redirect, and when should each be used?

A3: The canonical URL and 301 redirect are important SEO tools for handling duplicate content and URL management, but their application scenarios are different.

  • 301 Redirect:It is a server-side permanent redirect that tells the browser and search engines "This page has permanently moved, please visit the new address". When the old URL is no longer in use and it is desired that all visitors to the old URL