I am using editor for product description and there are HTML tags in them. Magento uses product description in product page meta tag description. My designs are going weird.

Here is the meta tag description.

<meta name="description" content="<p><strong>ABDE product</strong></p>
<p>Also available in <a href="domainname/index.php?route=product/product&amp;path=63_81&amp;product_id=188#.VkoVJuL642g"><span style="text-decoration: underline;"><strong>Black</st"/>
<meta name="keywords" content="Magento, Varien, E-commerce"/>

Ref Image : Click here

How to fix this issue. Any issue would be appreciated.

3 Answers 3


Add strip_tag function to eliminate HTML tags from meta description.

File location :


Search for the function _prepareLayout

Update the line

  $description = $product->getMetaDescription();


  $description = strip_tags($product->getMetaDescription());

For more details refer :http://connectonline.in/magento2-strip-tags-magento-meta-tags/


In recent versions this error has been corrected. Change this line to correct. app/code/Magento/Catalog/Block/Product/View.php:146

$this->pageConfig->setDescription($this->string->substr($product->getDescription(), 0, 255));


$this->pageConfig->setDescription($this->string->substr(strip_tags($product->getDescription()), 0, 255));



You have to check in adminpanel for that product.

Go to Admin -> Products 

Open Prodcut CLick on left sidebar,Search Engine Optimization tab

Check Meta Keywords field if it contens html tag then remove it. Or clear the value of meta keywords and check.

After that reindex your site.

  • Can we put htmlspecialchars char ? Commented Apr 22, 2016 at 13:32
  • you have to keep only text. Commented Apr 22, 2016 at 13:34
  • if i need to put htmlspecialchar ? Commented Apr 22, 2016 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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