How to Add Canonical URLs in Magento 2?

 

Canonical URLs are HTML elements that specify the preferred version of a web page to search engines. They help address the issue of duplicate content, which occurs when similar or identical content is accessible through multiple URLs. Having duplicate content can negatively impact search engine optimization (SEO) because search engines may have difficulty determining which version of the content to index and rank.

By adding a canonical URL to a page, you are indicating to search engines that this particular URL represents the authoritative or canonical version of the page. Search engines will then consolidate the ranking signals and attribute them to the canonical URL, helping to avoid duplicate content penalties.

When search engines encounter a canonical URL tag, they understand that the content on that page should be treated as the primary version, even if there are other URLs with similar content. This allows you to have multiple URLs pointing to the same content without being penalized for duplicate content.

Canonical URLs are Beneficial in various scenarios, including:

 

  • Different versions of the same page (e.g., a page accessible through HTTP and HTTPS).
  • Pagination pages (e.g., when content is spread across multiple pages).
  • Filtered or sorted pages (e.g., when users can sort products by price or popularity).
  • URL parameters (e.g., tracking parameters or session IDs).

Using canonical URLs ensures that search engines understand your preferred version of a page, consolidates ranking signals and avoids penalties for duplicate content. This can improve the visibility and SEO performance of your website.

  • To add canonical URLs in Magento 2, you can follow these steps:
  • Log in to your Magento 2 admin panel.
  • From the admin menu, go to Content -> Configuration.
  • In the Configuration panel, find the store view where you want to add the canonical URL and click on it.
  • In the Search box, type "canonical" to quickly find the Canonical URL setting.
  • Under the HTML Head section, expand the Canonical Link Meta Tag tab.
  • Set the Enable field to "Yes" to enable the canonical URL feature.

 

In the Default Canonical URL field, enter the default URL that you want to use as the canonical URL for your store. This URL should be the preferred version of your page that you want search engines to index.

If you want to use a different canonical URL for specific pages or products, you can override the default URL. In the specific page or product settings, you will find an option to enter a custom canonical URL. Enter the desired URL in that field.

Click on the Save Configuration button to save your changes.

Magento will now add the canonical URL tag to the HTML head section of your store's pages, specifying the preferred version of each page for search engines. This helps search engines avoid duplicate content issues and improves SEO by consolidating the ranking signals for your pages.