How to Add Canonical Tags in Magento 2.0 for CMS Pages
You can create canonical tags for Product and Category pages on Magento, but for some reason, you can’t create it for CMS pages. While looking for a solution, most of the documentation I found says Magento does not automatically add canonical tags for CMS pages. And that you need to leverage the Layout Update XML located in the Design section of the CMS page by inserting a custom code. But this seems to only work for Magento 1.0.
Canonical Tags in Magento 1.0 Pages
The documentation I found follows this procedure:
1. Click on CMS
2. Click on the Page you want to add canonical tags
3. Click on Design
4. Insert the following code into Layout Update XML
It seems to work for others on Magento 1.0 but I tried this custom code for Magento 2.0 and it didn’t work!
Canonical Tags in Magento 2.0 Pages
Similar to Magento 2.0, I followed this procedure:
1. Click on Content
2. Click on Pages
3. Click on Select > Edit for the page you want to add canonical tags
4 Click on Design
5. Insert the following code into Layout Update XML
I tried this custom code for Magento 2.0 instead and it worked beautifully!