1

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

2

Add strip_tag function to eliminate HTML tags from meta description.

File location :

/vendor/magento/module-catalog/Block/Product/View.php

Search for the function _prepareLayout

Update the line

  $description = $product->getMetaDescription();

With

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

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

1

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));

to

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

Reference:https://mage2.pro/t/topic/161

0

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.

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

Your Answer

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

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