How to Add Canonical Tags in Magento 2?

How to Add Canonical Tags in Magento 2

Are you looking to add Canonical tags in Magento 2?

Adding canonical tags in Magento is the best way to show the original page to the crawlers and avoid duplicacy issues.

Wondering why you need canonical, as you only published unique content. Read on, and you will find the answer.

In this quick tutorial, we will learn how to add canonical tags in Magento 2 and more.

What are Canonical tags?

A page does not need to have one URL. As humans, we see the page but the Google bots see the URL. If there are several URLs loading the one page, they will conclude that all these pages are duplicate. We think that this is the same page loading through the different URLs.

Most common example, a site that loads on:

  1. http://domain.com
  2. https://domain.com
  3. http://www.domain.com
  4. https://www.domain.com

All four URLs will load the homepage. But Google crawlers determine 4 different URLs and 4 different pages. There is only one page so crawlers consider it duplicacy.

Duplicate content is complicated to understand. Google fails to evaluate which page to rank higher.

Canonical tags clear that misunderstanding for Google. It tells which URL is the primary and other URLs are canon.

By knowing the original and canon URLs, Google crawlers can easily give the priority to the original one without accusing other of plagiarism.

Why do you need Canonical Tags in Magento 2?

Magento is an ecommerce platform used by mostly enterprises. Typically, Magento stores have thousands of products.

The store owners enable faceted navigation and filtering so the customers can search what they are looking for.

The category pages, search pages and navigation pages end up with such URLs:

  • https://magentostore.com/men/caps-men?p=2
  • https://magentostore.com/men/caps-men?brand=nike&size=168
  • https://magentostore.com/men/caps-men?price=30-40

If the category path is displayed in the product URL, then the number of URLs leading to one product increases – as one product could be in multiple categories.

  • https://magentostore.com/men/cap
  • https://magentostore.com/gear/cap
  • https://magentostore.com/sport/cap
  • https://magentostore.com/travel/cap

In both the cases, the URLs are different but the pages are the same. Users will not see the difference, but Google and other search engines certainly will.

Google will get confused which page to rank, and which page to hide. SEO understands this and fixes it with canonical tags. 

A canonical tag calls out the original page and solves the issue for the crawlers. Google ranks that page and other URLs become the secondary version.

How to Add Canonical Tags in Magento?

To add the canonical tags to any page, you have to add the rel=’canonical’ attribute to the <head> part of the page. So you need to edit the page code.

Magento is a powerful ecommerce CMS platform. It comes with many amazing features. And one of them is adding canonical tags to products and category pages.

Navigate to Stores > Configuration > Catalog > Catalog > Search Engine Optimization.

Scroll down to find the last two options of the section.

Add Canonical Tags in Magento 2

Use Canonical Link Meta Tag For Categories: To canonicalize the category variation pages

Use Canonical Link Meta Tag For Products: To canonicalize the product variation pages

Once these options are enabled, canonical tags will be added to your product and category pages. 

Wrap Up

A one line of code rel=’canonical’ can save your page from Google penalty (plagiarism) and improve your store ranking.

Magento makes it easier to add the canonical attribute to the pages. In this tutorial, we learned how to add canonical tags in Magento 2.

If you encounter any issue, feel free to leave it in the comments below.

Latest Magento Tips, Guides, & News

Stay updated with new stuff in the Magento ecosystem including exclusive deals, how-to articles, new plugins, and more. 100% Magento Goodness, a promise!

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top

🎉 CYBER MONDAY SAVINGS 🎉

75% OFF on
ALL PLANS

Receive the coupon as soon as you
submit the email address. 🚀