Magento Canonical URL for CMS Pages via Layout XML
February 28, 2014 10:40 am |
Magento has some great functionality for various SEO related elements, one of which is a setting to dynamically add the canonical url tag to pages for you. Despite this Magento doesn’t currently add the canonical url markup to static cms pages automatically.
This however is not an issue as we can simply place the following code into each static cms pages, custom layout update xml.
Ensure that you replace the url contained between the: <href></href> tags with your static pages full url.
How to Add the Canonical URL Tag
Simply follow the steps below to place the additional xml layout update code in each of your sites static cms pages.
Login to the magento admin panel of your site.
Navigate to the ‘cms’ link on the admin navigation and click ‘pages’ link on the sub nav drop down menu.
Click on the static cms page that you wish to add the canonical url tag to from you list of pages.
Click the ‘design’ link on the left hand side navigation menu.
Scroll down the page and locate the content area labelled ‘Custom Layout Update XML’ and paste the canonical url xml update code detailed in this post into this text box.
Ensure that you have changed the url to the full, live url of the particular page that you are editing between the <href></href> tags.
Now click the ‘save page’ button and view the source code of the live page that you have just edited. The canonical url tag should now be within the <head></head> tags of the page.