Magento – Add Open Graph Tags in Meta

Ah…. Big mistake.

Magento has good plugin called Creare SEO (http://www.magentocommerce.com/magento-connect/creare-seo.html).

It has Twitter Cards and Open Graph. Install above plugin.

——

Discard below contents

Open template’s header file and add below after any existing meta tag.

Change ‘images/logo.png’ to your logo. Other meta tags will be automatically filled.

<meta property="og:title" content="<?php echo $this->getTitle() ?>" />
<meta property="og:description" content="<?php echo htmlspecialchars($this->getDescription()) ?>" />
<meta property="og:type" content="website" />
<?php if (Mage::registry('current_product')) : ?>
<meta property="og:image" content="<?php echo Mage::helper('catalog/image')->init(Mage::registry('current_product'), 'image')->resize(200,200);?>" />
<?php else: ?>
<meta property="og:image" content="<?php echo $this->getSkinUrl().'images/logo.png'; ?>" />
<?php endif;?>
<meta property="og:url" content="<?php echo Mage::helper('core/url')->getCurrentUrl();?>" />
<meta property="og:site_name" content="<?php echo $this->getTitle() ?>" />
<link rel="canonical" href="<?php echo Mage::helper('core/url')->getCurrentUrl();?>" />

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.