How to set up a canonical link (CanonicalUrl) in article content and ensure it displays correctly on the page?

Calendar 👁️ 80

In website operation, we often encounter situations where content is similar or duplicated, which may not only scatter the search engine crawling budget, but also dilute the page weight, affecting the SEO performance. 幸运的是,AnQi CMS has provided us with the function to set the canonical link (Canonical URL), which can effectively help us solve these problems, clearly telling search engines which page is the "original" or "preferred" version of the content.

Understanding the value of the canonical URL

In simple terms, a canonical link is like a 'home page signpost' for search engines. When multiple URLs point to pages with very similar or identical content on your website, for example:

  • There are multiple colors for the same product, each color corresponds to a URL, but the core product description is mostly consistent.
  • The article is categorized under multiple different categories, resulting in different URL paths but the same content.
  • The page URL includes tracking parameters (?utm_source=...), causing multiple parameterized URLs on the same page.
  • Pages with consistent content but different URLs are used on different devices (such as PCs and mobile phones) if the website is not adaptive or code adaptation mode is not enabled.

In this case, if not explicitly specified, the search engine may be confused about which page is the 'authoritative' version, and may even misjudge it as duplicate content and lower the rankings of all related pages.Set the standard link to avoid this kind of confusion, ensure that the search engine can accurately understand the structure of your website, and concentrate all related signals (such as link weight, ranking signals) on the homepage you specify.

Set the standard link in the Anqi CMS backend.

The design of Anqi CMS fully considers SEO requirements, the process of setting up standard links is very intuitive.

When editing or publishing a new article, product, or single page, you can find a dedicated field to configure standard links.As a rule, at the bottom of the content editing page, you will see a collapsible area named "Other Parameters".Click to expand this area and find the item "Canonical URL".

Here, you need to enter the complete URL of the page you want the search engine to consider as the main version. This link must end withhttp://orhttps://starts and is a directly accessible complete address, for examplehttps://en.anqicms.com/article/98.If you want the current page to be recognized as the original page by search engines, it is usually best to leave it blank, and the system will default to using the URL of the current page as the standard link.But if the content on the current page is copied from other sources (such as external websites) and you want the search engine to pass on the weight to the original author's website, or if your page is indeed a variant of some "main page", then this is the place to specify the main page URL.

Ensure that the standard link is displayed correctly on the page

The link set in the background is not enough, we need to ensure that this link can be displayed correctly in the HTML code of the web page, so that the search engine spiders can read it.The Anqi CMS uses template tags to allow us to flexibly output this information on the website front-end.

In the template files of the website, we use{% tdk %}Tags to handle the TDK (Title, Description, Keywords) information on the page, and standard links also belong to this kind of important<head>Tag content.

Generally, the header template file of a website (such asbase.htmlor the public header file referenced by the article/product detail page) is where such global information is placed<head>The ideal position for a label. In this file,<head>you can add the following code to call the specification link:

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

It is worth noting that we used{%- tdk canonical with name="CanonicalUrl" %}This way to define a variable namedcanonicalIt will fetch the value of the "standard link" set in the background. Then, we use{%- if canonical %}to make a judgment. Only whencanonicalThis variable has a value (i.e., you have set specific specifications for this page in the background) when,<link rel="canonical" href="{{canonical}}" />this line of HTML code will be output to the page.

The benefits of doing this are multifaceted:

  1. Code concise:Avoids outputting empty on pages without a specified link<link rel="canonical">Tags, keeping the HTML code neat.
  2. Accuracy:Ensured that only when you explicitly specify the specification link, the search engine will see and follow your instructions.
  3. Follow **Practice:**This is a commonly recommended practice in the SEO field, which can effectively avoid potential misunderstandings.

By following these steps, you not only specified the standard link of the page in the Anqi CMS backend, but also ensured that it could be correctly identified and applied by search engines, thereby optimizing the performance of your content in search results and consolidating the page authority.


Frequently Asked Questions (FAQ)

1. If I haven't specifically set a standard link, how will AnQi CMS handle it?

If you do not manually fill in the 'standard link' for a page in the 'other parameters' section of the background, AnQi CMS will usually default to using the URL of the current page as its own standard link.This means that in most cases, the search engine will still consider the current page to be the original version of the content.Although this is a reasonable default behavior, when encountering pages with highly similar content or multiple URL parameters, manual settings can provide more precise control and stronger signals, avoiding potential confusion for search engines.

2. What is the difference between a standard link and a 301 redirect, and how should I choose?

The canonical URL isRecommendedIt tells the search engine which URL is the preferred version, but the search engine retains the final decision-making authority.Pages that are similar in content but cannot be redirected simply are usually used, such as print versions, URLs with tracking parameters, or products with slight variations but consistent main content.MandatoryIt tells the browser and search engines that the page has permanently moved to a new address, and will direct both users and search engines to the new URL.301 is used for situations where the page URL has a permanent change (such as website redesign, page deletion and merging).Choose the method that suits your specific needs: if the content still exists in multiple URLs but you want to concentrate the weight, choose the standard link; if the content has been completely transferred from the old URL to the new URL, choose 301 redirect.

Can the canonical URL point to a page on an external website?

Technically, it is possible.If you publish content on Anqi CMS that is转载自 other websites, and you want search engines to know the original source and direct weight to the original author's website, you can fill in the external website URL in the standard link.This is very useful in content distribution and copyright attribution.Your websiteThe internal URL to consolidate the weight and ranking of your own website.Unless you have a specific purpose (such as declaring转载or participating in content co-publication), it is generally not recommended to link specifications to external websites.

Related articles

How to traverse an array and control display style with loop tags (for) in AnQiCMS templates?

During website operation, we often need to display various list data, such as article lists, product lists, image galleries, or navigation menus.AnQiCMS (AnQiCMS) provides a powerful mechanism based on the Go language template engine, where the `for` loop tag is the core tool to meet this requirement.By flexibly using the `for` tag and its auxiliary functions, we can easily traverse array or list data and accurately control the display style of each element according to actual needs.

2025-11-08

How to call data from other sites in a multi-site environment using the siteId parameter?

In the multi-site environment of AnQiCMS, data intercommunication is a key factor in improving operational efficiency and achieving content integration.Sometimes, we may need to display the content of a sub-site on the main site, or call the contact information of another brand site in a business site.At this time, the `siteId` parameter provided by AnQiCMS is particularly important, as it helps us easily implement cross-site data calls and display.### Understanding the multi-site advantages of AnQiCMS AnQiCMS was initially designed with the need for multi-site management in mind

2025-11-08

How to debug variable content and type in AnQiCMS template (using dump filter)?

When using AnQiCMS to build websites and customize templates, we often encounter situations where the content displayed on the page is not as expected, or it seems that a variable is not passing correctly.At this moment, it is particularly important to be able to quickly view the actual content and data type of variables in the template.Fortunately, AnQiCMS's template engine (which adopts a syntax similar to Django) provides us with a very practical tool—the `dump` filter, which helps us easily reveal the mysteries of variables.### Core Function: `dump`

2025-11-08

How to implement pagination display and like function for comment content in AnQiCMS?

In website operation, user comments and interaction are the key to enhancing the vitality of content.AnQiCMS (AnQiCMS) provides powerful content management capabilities, among which the comment feature is an important bridge for user interaction with content.This article will discuss in detail how to implement pagination for comment lists in Anqi CMS, as well as add a like function for comment content, enhancing the interactive experience of your website to a higher level.### CMS Review Function Overview The CMS has built-in article comment and comment management functions from the early version, which provides native user interaction support for the website

2025-11-08

How to configure and display structured data (Json-LD) in AnQiCMS to enhance search engine understanding?

In today's digital world, search engines are the main way users discover website content.In order to help search engines better "understand" the content on our website, structured data plays a crucial role.Json-LD (JSON for Linking Data) is a lightweight, easy-to-implement standardized data format that can clearly describe web content in a structured way, thereby enhancing the visibility and display effects of websites in search results.AnQiCMS as a content management system focusing on SEO optimization

2025-11-08

How to set a default thumbnail in AnQiCMS to ensure that articles without uploaded thumbnails can still display images?

It is crucial to maintain the visual appeal and consistency of content in website operation.Many times, the articles we publish may not have a specific picture, or the editor may have missed uploading the thumbnail, which may lead to blank pages or inconsistent styles.AnQiCMS (AnQiCMS) has fully considered this user requirement and provided flexible default thumbnail setting features to ensure that even articles without individually uploaded thumbnails can have beautiful image displays.Why do you need to set a default thumbnail?\n\nA default thumbnail is like a "backup plan" for a website.

2025-11-08

How to automatically convert newline characters in multi-line text in AnQiCMS templates to the HTML `<br/>` tag?

In AnQiCMS template, how to make the newline character of multiline text automatically display as the HTML `<br/>` tag?In website content operation, we often encounter situations where we need to display multi-line text, such as article summaries, product descriptions, or user comments.This text content is usually created by pressing the Enter key when editing in the background.However, when this text containing newline characters (usually `\n`) is directly output to an HTML page, the browser will not parse it as a visual line break.On the contrary, HTML

2025-11-08

How to configure custom parameters in the background of AnQiCMS and flexibly call and display them in the front-end template?

In website operation, we often encounter the need to add personalized information outside of standard fields for content or the global website.This information may be a description of the unique features of a website, product parameters, specific attributes of an article, or even multi-channel contact information.AnQiCMS (AnQiCMS) fully understands the importance of this flexibility, and therefore provides powerful custom parameter configuration features, allowing you to easily define the required data in the background and flexibly call and display it in the front-end template.

2025-11-08