for almost 2 days looking for information, but I can not find how to change this og tag only for index page (frontpage) of Magento. Do you have ideas how to do it?


You could try with an if statement in your head like :

if(Mage::getBlockSingleton('page/html_header')->getIsHomePage()) {
  // Insert og:image meta

or with the page identifier like :

Mage::getSingleton('cms/page')->getIdentifier() == 'home' &&
Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms'
) :  {
  // Insert og:image meta

EDIT : To double check, I just tried in one of my sites to add to app/design/frontend/default/my_theme/template/page/html/head.phtml :

<?php if(Mage::getBlockSingleton('page/html_header')->getIsHomePage()) { ?>
    <meta property="og:image" content="<?php echo $this->getBaseUrl() ?>media/og-image.jpg" />
<?php }; ?>

And it works fine.

  • Hello @David, I try your suggestions, but they not working. Are you having other ideas on that? – Nasku Nov 29 '16 at 12:15
  • Please check edit, I just tested it out. – David Nov 29 '16 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.