Magento 1.9 – Adding Code to Head Section of Homepage

headlayoutmagento-1.9

How do I add code to the head of my homepage only? I did some research and I think it needs to go into layout.xml under but it doesn't seem to be showing. My code with this added is below:

<cms_index_index>
        <update handle="MAP_popup"/>
        <reference name="head">
<link rel="alternate" href="https://www.MYURL.com/" hreflang="en" />
<link rel="alternate" href="https://www.MYURL.com/spanish_store/" hreflang="es" />
<link rel="alternate" href="https://www.MYURL.com/portuguese_store/" hreflang="pt-br" />
            <action method="addJs" ifconfig="mango_settings/newsletter_popup/enabled"><script>smartwave/jquery/jquery.cookie.js</script></action>
        </reference>
        <reference name="before_body_end">
            <block type="newsletter/subscribe" name="newsletter_popup">
                <action method="setTemplate" ifconfig="mango_settings/newsletter_popup/enabled"><template>newsletter/popup.phtml</template></action>
            </block>
        </reference>
    </cms_index_index>

The section I added (and need to add) is:

<link rel="alternate" href="https://www.MYURL.com/" hreflang="en" />
<link rel="alternate" href="https://www.MYURL.com/spanish_store/" hreflang="es" />
<link rel="alternate" href="https://www.MYURL.com/portuguese_store/" hreflang="pt-br" />

Thanks in advance.

Best Answer

You could look at doing the following:

<cms_index_index>
    <reference name="head">
        <block type="core/text" name="my-block">
            <action method="setText"><text><![CDATA[<link rel="alternative" hreflang="en" href="https://www.MYURL.com/" />]]></text></action>
        </block>
    </reference>
</cms_index_index>
Related Topic