How to Add Canonical URL in Magento 2? (Complete Guide)

How to Add Canonical URL in Magento 2? (Complete Guide)

If you are searching for ‘Magento 2 set canonical URL’, then you are at the right place. In this article, we will discuss everything there is to know about:

  • Add canonical tag to product pages
  • Add canonical tag to homepage & other CMS pages
  • Add canonical tag to any category page
  • Add cross domain canonical tag
  • Add canonical tag to pagination & category filters
  • Lots more

So, let's get started by first developing an understanding of canonical URLs.

What are Canonical URLs?

By now, you know that if you upload duplicate content, search engines will deindex your website promptly or apply some other penalty. However, in some cases, website owners have no choice but to use duplicate content (we will discuss more about this in detail later).

To avoid content duplication penalty from the search engines, the best course of action is to select one URL to index. Google and other search engines will only display the selected URL in search results. This allows you to keep multiple pages with duplicate content but without having to worry about any penalty.

Reasons Behind Duplicate Content

There are several reasons why a website may have duplicate content. Let’s examine a few of them in detail.

Region Variants

The topmost reason why websites have duplicate content is because there are two same webpages but for different regions. Suppose your store sells in the UK and the US. For whatever reason, you have two separate pages – one for the UK audience, and one for the US. It makes little sense to have different content for both pages since both pages serve the same purpose.

Device Variants

Similarly, a few websites have set up different versions for desktop and mobile phone users. Again, although they are two different pages, they have the same content.

Protocol Variants

Additionally, your website may have two webpages – one with HTTP and the other with HTTPS. From the crawler’s perspective, they are two different pages. So, you’ll have to determine which one to index.

Other Reasons

Other common reasons include failing to remove demo or test pages before getting the website live.

Content Duplication in eCommerce

Content duplication is a common issue in e-commerce stores. This is because e-commerce stores have a lot of unique pages with almost the same content. For example, multiple products or category pages may have the same or very similar content i.e. product descriptions, features, guidelines, etc. This can also happen if you have a snippet of text that appears on multiple pages.

Having a short duplicate content is OK but if it exceeds 100 words, Google may think of it as a copy of another page with a distinct URL leading to content duplication issue. This is where the concept of canonical tags comes into play. A canonical tag on a page tells search engines that this page is an exact copy of the destination URL and hence should not be treated as a unique page.

Best Practices for Magento 2 Set Canonical URL

Keep in mind that setting a canonical URL does not indicate the crawler will accept your request. Remember, the canonical URL is a hint, not a rule. To improve the probability of the crawler accepting the canonical URL, follow these best practices:

  • Never use the robots.txt file for setting a canonical URL since it serves a very different purpose.
  • When interlinking on your website, always link to the canonical URL.
  • Don’t use a URL removal tool as it removes all URLs.
  • When using multiple canonical methods, don’t set different URLs as the canonical URL.

How to Use the Extension to Add Canonical Tags in Magento 2?

Although Magento 2 allows adding/implementing canonical tags from within its admin panel, the choices are very limited. Therefore, we believe that the best way to add canonical tags in Magento 2 is through a third-party extension. For this article, we will implement the canonical URLs using the Magento 2 Canonical URL Extension that offers some advanced features when it comes to adding a canonical tag.

1. Add Canonical Tag To Product Pages

The extension allows you to add a canonical tag for each product page from the product edit sheet with the following options.

  • Custom URL
  • Use Config (Canonical tag you have set for all products from configurations options)
  • Canonical URL with Category Tree
  • Canonical URL without Category Tree

Go to any product from backend and expand the Search Engine Optimization section.


2. Add Canonical to CMS Pages

To add canonical URL to CMS page in Magento 2, Open:

  • Admin Panel, navigate to Content -> Pages
  • Click on Edit page & expand the Search Engine Optimization section
  • Enter a custom URL to override the default canonical URL

In this way, you can easily add canonical URL to homepage as well.

3. Add Canonical Tag to Any Category Page

To add canonical URL to category page in Magento 2, Open:

  • Admin Panel, navigate to Catalog -> Categories
  • Select any Category & tap the Search Engine Optimization tab
  • Enter a custom URL to override the default canonical URL


4. Configure Cross Domain Canonical Tag

You can configure the addition of canonical Meta tag to a storefront, store view, or a custom URL as well.


5. Exclude Specific Pages From Canonical Tags Application

With the help of the extension, you can exclude specific product or category pages from canonical tags application.


6. Add Canonical Tag For Pagination & Category Filters

This feature allows you to add a canonical tag to pagination pages. You can also elaborate relativity of layered navigation pages to products and category pages.

  • Enable/Disable Canonical Meta tag to catalog pagination pages
  • Allow/Disallow Canonical Meta tag to catalog layered navigation – for filtered or current category page


7. Add Trailing Slashes

To make the most of this extension in terms of SEO, add trailing slash for canonical Meta tag. This will make your store’s URLs user and search engine friendly.


This Magento 2 Canonical URL extension is a complete content duplication solution. It makes canonicalization super easy to implement. With the introduction of the above extra features, it makes your pages more crawlable and search engine friendly while improving the ranking signals for content available through multiple URL structures.


That’s it for this tutorial. If you have any issue in adding canonical tags in Magento 2, then ask our expert Magento support team.

Related Articles: