Magento 2 Canonical URLs: Enable, Edit, Customize

Websites offering similar or the same content on multiple pages or using pagination extensively are facing content duplication issues. Unless they use Magento canonical URLs. Canonical tags make sure Google uses the "right" version for indexing and doesn't penalise your content. 

While canonical tags are part of the Magento SEO best practices, the platform offers canonicals for a limited number of pages. 

In this guide, you'll learn how to enable canonical URLs in Magento, how to set them for content pages and how to customise any existing canonical URLs.

What is Magento Canonical URL?

Magento canonical URL (also known as Magento canonical tag) is an SEO tool that allows specifying the "main" version of the page, so Google and other search engines know which page to index in case there are very similar or duplicate pages on a website.

Canonical tag helps you to make sure Google indexes the "right" version of the page, if, for example, a product page is part of multiple categories and you include the category path in product URLs.

e.g.
https://yourwebsite.com/sunglasses
https://yourwebsite.com/sale/sunglasses
https://yourwebsite.com/black/sunglasses

Note: canonical tags are usually marked as rel="canonical" in the

tag of the page. Use the Ctrl + U combination or browser dev tools to open the page source code and find them on the page. 

Canonical Tags in Magento 2

Now, let's dive into more cases when Magento canonical tags come in handy.

Why You Need Canonical Tags?

Canonical tags are extremely important for eCommerce websites, like Magento, because of the URL diversity created by filters and parameters.

Magento uses faceted navigation and filtering to help customers find products that fit their needs. It results in parameterised URLs like:

e.g.
https://yourwebsite.com/men/tops-men?p=2
https://yourwebsite.com/men/tops-men?climate=201&size=168
https://yourwebsite.com/men/tops-men?price=30-40

Besides, if you configure the category path to be displayed in the product URL, you'll eventually get multiple URLs that point to the same page:

e.g.
https://yourwebsite.com/men/beaumont-summit-kit
https://yourwebsite.com/gear/beaumont-summit-kit
https://yourwebsite.com/sport/beaumont-summit-kit
https://yourwebsite.com/travel/beaumont-summit-kit

In both examples, your website visitors will see the page as one. So it makes no difference to them. However, if you don't add canonical URLs in Magento, search crawlers will consider all of these URLs as unique pages

As a result, search engines have to choose what version of the page to index and rank and end up indexing the wrong page or nothing at all. That's why you need to use canonical tags to control what gets indexed.

How Do Default Magento Canonical URLs Work?

Magento provides canonical URLs for products and categories by default. To enable them, navigate to Stores > Configuration > Catalog > Catalog > Search Engine Optimization and enable them for the corresponding pages there.

However, there's no option to add canonical to Magento content pages or any other page.

Magento Canonial Meta Tags

Default Magento canonical URL settings

How to Add Canonical URLs in Magento?

To add canonical URLs to Magento pages other than products and categories, you need the Magento SEO Extension. Once you install it, navigate to Stores > Configuration > Magefan Extensions > SEO > Canonical Tag and enable canonical tags for multiple pages.

add canonical tags in magento

Canonical tag settings in the Magefan SEO Extension

Canonical tags for CMS pages

To add a canonical URL to Magento CMS pages or the homepage, enable the Canonical Tag For Homepage and Canonical Tag For CMS Pages options.

Canonical tags on homepage

Canonical tag on Magento homepage

Canonical tags for blog pages

If you want to enable canonical tags for your Magefan blog pages, do that from the SEO extension settings (Stores > Configuration > Magefan Extensions > SEO > Canonical Tag) or via blog settings directly ( Stores > Configuration > Magefan Extensions > Blog > Search Engine Optimisation).

add canonical tags for magefan blog pages

Canonical tag settings for Magento blog

How to Add Custom Canonical Tags in Magento?

Unfortunately, you can't set custom canonical tags in Magento by default. With the Magefan SEO extension, you can enable canonical URLs for custom pages, that don't have any canonical, or pages that you want to set the custom canonical for.

Enable canonical URL for custom Magento pages

To add canonical URLs for custom pages in Magento, enable the Canonical Tag For Specific Pages option in Stores > Configuration > Magefan Extensions > SEO > Canonical Tag section and paste the URLs in the Specific Pages field.

add canonical tags for specific pages magento

Custom canonical tags settings

Set custom canonical URL for any Magento page

To change existing canonical URLs in Magento or set custom canonical, you need to create an SEO rule with the Magefan SEO tool.

Use case: when we go to the Men > Tops category (website.com/men/tops-men.html) and filter products by category Jackets we get the following URL — website.com/men/tops-men.html?cat=14. The canonical for this page is still website.com/men/tops-men.html.


So we'll change that canonical to something else.

canonical tags in magento 2

Example of the canonical tag for page with parameters (Magento)

To add custom canonical tags in Magento:

  1. Navigate to Marketing > SEO by Magefan > SEO Rules and press the Add New SEO Rule button. 
  2. Enable the rule, and set a Name and Priority for it.
  3. Choose a Specific Page as a Page Type
  4. Set the URL of that page and specify the Canonical URL for it to override. 
magento 2 custom canonical tag

Custom canonical tags in Magento SEO rules

Note: Magefan SEO rules come with multiple other options, like Magento meta tags templates, custom H1 tags, etc. If you only want to set custom canonical tags for a page, skip all other fields.

Once you Save the rule, a custom canonical tag is applied to a specified page. 

custom magento 2 canonical tags

In our case the URL is changed to the Men > Tops > Jackets category (website.com/men/tops-men/jackets-men.html) that was used in the filters. The best part is you can choose literally any page to add custom canonical tags to. Products or categories work too.

FAQs

Is there a Magento 2 Canonical URL Extension?

collapsible icon
Yes. There are extensions dedicated to enabling canonical URLs for pages Magento doesn't cover by default. However, it's recommended to use the SEO Suite Extension that does the same by default, along with other SEO features.

How to override product canonical URL in Magento?

collapsible icon
It's possible to override product canonical URL in Magento using the custom canonical tag rules in the Magefan SEO Extension.

Just navigate to Marketing > SEO by Magefan > SEO rules and create a new rule overriding the canonical for any page, including products.

How to display custom canonical URL on category page in Magento?

collapsible icon
You can set custom canonical URL for Magento categories using the SEO rules available in the Magefan SEO Extension. It allows you to add custom canonical directly from the admin panel.

Just specify the category URL and the custom canonical you want to add or it.

How to set canonical tag for homepage in Magento?

collapsible icon
To enable canonical URL for Magento homepage, navigate to Stores > Configuration > Magefan Extensions > SEO > Canonical Tag and enable the "Enable Canonical Tag for Homepage" option.