Canonical urls magento is an important factor in SEO that doesn’t only assign you manage and control canonical setting on each page of your site, but also it helps to remove duplicate content and better distribute link juice. As a result, your website becomes SEO-friendly and ranks at the top of the search engine. Magento 2 allows you to enable canonical URLs for products and categories. And adding canonical URLs in Magento 2 is an effective solution to direct search engines to a single canonical URL for indexing thus avoiding duplicate content.
What is a Canonical urls magento?

Canonical urls magento is an address that is selected as a preferred one for search engine ranking or indexation. Also, many people say that canonical tag is an HTML attribute, which you apply to web pages to show search engines where to assign the search value.
The process of canonicalization is crucial for webpages with duplicate content or similar content. Hence, you can point out which webpage is the main. Let’s suppose that you have these webpages for the same product or services:
- magesolution.com/ magento2extensions /magento2solution.html
- magesolution.com/magentosupportservices/ magento2solution.html
- magesolution.com/magentothemedesigner/ magento2solution.html
- magesolution.com/magentocodeaudit/ magento2solution.html
If you won’t make any settings on your Magento 2 store, search engines will automatically select one of them as canonical regarding it the most relevant. This means you won’t be able to control the choice, until making any adjustments. It is main reason for showing search engines which one is canonical and set the 301 redirect for all the rest.
Why canonical tag is crucial for SEO in Magento 2?
If duplicate content is detected in your Magento 2 website at a high amount, Google may restrict you and give your domain a penalty and downranking. For an eCommerce Magento 2 website, this is a common issue because of the high variation in URLs. With right use of the canonical tag, you can showcase the crawlers on which link should be the original and improve all the ranking power. Moreover, you can easily make the changes in product pages with variations such as size, colors, etc. Product belonging to multiple categories is a perfect solution for Magento 2 website.
Also read: Magento breadcrumbs: Types, benefits and how to add/ delete it in Magento 2
How to add Canonical URLs in Magento 2

Including the canonical URLs can go from being simple to mildly complicated, basing on which kind of page that you need to add it to.
For categories and products
The process of adding canonical URLs in Magento 2 for categories and products is relatively simple. All thing you need to do is enabling one or two settings in the Magento Admin Panel in order to have canonical URLs automatically created
First step, you move to your Magento account and click on Stores > Settings > Configuration
For CMS pages
However, creating canonical URL for CMS page in Magento 2 can be a little bit of a challenge. Magento 2.4.3 version don’t support you to custom code in the Custom Layout Update anymore. But don’t worry, Magesolution will show you how to implement it in this article.
- Firstly, you need to move the page you want to add canonical URLs.
- Then, we need to generate an .XML file with layout updates and custom it from the backend in Layout Update XML. The filename of XML files should use the format:
cms_page_view_selectable_<CMS Page Identifier>_<Name for Layout Update>.xml
For example: cms_page_view_selectable_about-us_test.xml
- After that, fill it with the following syntax:
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <head> <link rel="canonical" src="http://example.com/about-us" src_type="url"/> </head> </page>
- Replace http://example.com/about-us with your selected canonical URL, and the above command line will add a canonical URL (http://example.com/about-us) into your CMS page’s
<head>
. - After that, you place this file in (your_Magento_root)\vendor\magento\theme-frontend-luma\Magento_Theme\layout, and flush cache using:
- You should now be able to see a selectable
test
option in your Magento Admin Panel. Move to Content > Pages > About Us > Design > Custom Layout Update and select test.
- Save configuration and refresh your frontend. When inspecting your About Us page, you should now see a canonical URL in the page’s
<head>
:
For Homepage
Similarly, you can also add canonical tag to homepage in Magento 2 with the same way as CMS Page’s.
Summing Up
That’s all about Canonical urls magento and the effective ways to add it in Magento 2 . If you have any problems when following our instruction, then you can get in touch with Magento experts for any free support. Magesolution can help you as we have a range of choices in extensions, and can help you build a custom one for you to keep your Magento 2 store SEO friendly and safe. Contact with us to know more!