Magento – Automatically Generated Meta Tags

meta-tagsPHP

I have a multi language store in magento 1.8ce

Meta title
Same as The title of The product

Meta desciption
I use a combination of The title, sku and description (with The html tags)

Meta keywords
The description with The html tags

How can this be automated?
And The html tags being striped from The description?
And also automatically use The description and title from The right language store.

Best Answer

You can modify the default Magento page meta tags by customising the phtml in the head.phtml file of your theme at

app/design/frontend/YOURTHEME/default/template/page/html/head.phtml

For example to modify the meta description for a product you could do something like :

<?php
$_metaDescription='';
if (Mage::registry('current_product'))
{
  // auto generate meta description
if (strip_tags(Mage::registry('current_product')->getDescription())=="")
{
    $_metaDescription=htmlspecialchars($this->getDescription());
} else {
      $_metaDescription=strip_tags(Mage::registry('current_product')->getDescription());
}
} else {
     $_metaDescription=htmlspecialchars($this->getDescription());
}
?>
<meta name="description" content="<?php echo $_metaDescription ?>" />

This example checks that the current frontend view is a product, and if a product (long) description exists strips the tags from the description text and sets the meta description to this text.

You can modify this further to include product name, sku etc.

Note the description should optimally be between 150-160 characters, so you should check the output of your meta description to see if it is meaningful and within these limits.

I would advise against adding the description text to the meta keywords field. Google pretty much ignores the meta keywords content these days, and if you want to try and use this for SEO keywords then a single relevant keyword or search phrase will have more SEO significance than the product description text.

More information regarding modifying the meta content can be found here

http://blog.gaiterjones.com/magento-seo-generate-meta-description-tags-automatically/

Related Topic