While creating Open Graph extension in Magento I came across an issue- although my metatag is correct, facebook cannot catch my og tag because there is too much code before my meta/og tag.
Has anyone else encountered this and do you have any suggestions?
<reference name="head">
<block type="catalog/product_view" name="product.opengraph">
<action method="setTemplate">
<template>socialtag/opengraph_product.phtml</template>
</action>
</block>
</reference>
Best Answer
Here's an alternative solution. It's not nice, and should be considered a hack. It also goes against the purposes of Magento's layout system. Nonetheless, if your requirement is not to override the base head template, then try this:
Inject Content via Event Observer
In your module config XML, add the following event:
And then you would create an observer class to match:
So far as I can see, this is only way to solve your problem. Neither the stock head block nor its base template make provisions for adding
meta
tags above its call for child HTML.