Magento Canonical URL for CMS Pages via Layout XML

Categorised in: ,

February 28, 2014 10:40 am | Published by Matt

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.

<reference name="head">
    <action method="addLinkRel">
        <rel>canonical</rel>
        <href>http://www.yoururl.com/goes/here.html</href>
    </action>
</reference>

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.

Step 1)

Login to the magento admin panel of your site.

Magento admin login screen

Step 2)

Navigate to the ‘cms’ link on the admin navigation and click ‘pages’ link on the sub nav drop down menu.

Magento admin login screen

Step 3)

Click on the static cms page that you wish to add the canonical url tag to from you list of pages.

Magento admin login screen

Step 4)

Click the ‘design’ link on the left hand side navigation menu.

Magento admin login screen

Step 5)

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.

Magento admin login screen

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.

share this article: