July 14, 2020


Thinking Magento

Magento - The MetaDescription

Many have claimed that they have the ultimate metadescription patch for Magento and as far as I'm concerned. Many have tried and many have failed.

For me the following is what made successful use of the metadescription.

$content = htmlspecialchars($this->getDescription());
$content = str_replace("\n",'',$content);
$content = str_replace("\r",'',$content);
$content = preg_replace('/([\s]{2,})/',' ',$content);
$content = substr($content,0,250); ?>
<meta name="description" content="" />

Feel free to update your head.phtml file with it and see if it makes a difference for you.