When you add canonical tags in Magento 2 you ensure that the right version of the pages is indexed and ranked in search results. However, sometimes the canonicals you enable don't fit your SEO strategy. So you might want to change them.
Unfortunately, you can't set custom canonical tags in Magento by default. Not unless you use the Magento 2 SEO Extension. So, today you'll learn how you can easily change or set custom canonical tags for your store pages.
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.
To add custom canonical tags in Magento:
1. Navigate to Marketing > SEO by Magefan > SEO Rules and press on 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 and set the Custom URL of that page.
Note: you can skip the meta tags, H1 and meta robots fields if you only want to set custom canonical tags.
4. Specify the Canonical URL for a specific page.
Once you Save the rule, a custom canonical tag is applied to a specified page.
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.
However, custom canonical tags are still a small part of the SEO rules features. You can also configure metadata for multiple pages in bulk with meta tags templates to automate your store SEO.