Search code examples
xmlmagentolayouthead

Magento add canonical link to head section via xml


i'm trying to add my link to head section via my xml file, but nothing happens (magento 1.7.0.2)

<action method="addLinkRel"><rel>canonical</rel><href>http://fonts.googleapis.com/css?family=Dancing+Script</href></action>

please tell correct way.


Solution

  • Maybe something like this, showing complete layout XML structure:

    <?xml version="1.0"?>
    <layout>
    
        <default>
            <reference name="head">
                <block type="core/text" name="any.name.here">
                    <action method="setText"><text><![CDATA[<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Dancing+Script">]]></text></action>
                </block>
            </reference>
        </default>
    </layout>
    

    The setText lets you do pretty much anything, and will be a safe bet for any third party js or css.