Magento – SEO Meta Data
By default, Magento will display the default meta keywords and meta description on every page, something which is defined in the Configuration of the Magento store. Meta descriptions are vital in the performance of a site’s keywords, and it is believed on good grounds that duplicate meta descriptions throughout a site will be detrimental to its success. It’s better for an un-optimised page to have no description, rather than share the same description with 100s of other pages on the site.
The solution is a simple hack in the head.phtml file (app/design/frontend/default/yourtheme/template/page/html/head.phtml).
Paste the following code over the meta descritption and meta keywords tags:
<?php $checkd = "default";
$checkd2 = htmlspecialchars($this->getDescription());
if($checkd2 == $checkd){ } else { ?>
<meta name="description" content="<?php echo htmlspecialchars($this->getDescription()) ?>" />
<?php } ?>
<?php $check = "default";
$check2 = htmlspecialchars($this->getKeywords());
if($check2 == $check){ } else { ?>
<meta name="keywords" content="<?php echo htmlspecialchars($this->getKeywords()) ?>" />
<?php } ?>
Now if you go to: System > Configuration > Design > HTML Head
Type the word ‘default’ exactly into the default keywords and description fields and save. That’s all there is to it.
What the code does is check whether the keywords value is ‘default’, if it is it doesn’t show anything. If it’s not, it shows the keywords tag with the values you have otherwise specified. All CMS, category and product pages allow you to define unique keywords and descriptions.
