Why are html tags appearing in meta description for all my products?
-
16-10-2019 - |
문제
My meta description for all my products looks something like this:
meta name="description" content="<li>免費附贈專用腳踏幫浦一支</li>
<li>可使用標準嬰兒床單</li>
<li>安全護欄設計避免幼兒摔落</li>
Why is it including the <li>
tags? When I enter the products via admin console, I manually type it in in HTML format. But I didn't expect for it to appear in the meta description.
I certainly hope this doesn't show up in search engine listings.
AND, when I share to a social network, even the tags are being shared too.
Anybody know why this is happening?
해결책
I want to add a few informations.
The meta description is set here:
/app/code/core/Mage/Catalog/Block/Product/View.php:67
$description = $product->getMetaDescription();
if ($description) {
$headBlock->setDescription( ($description) );
} else {
$headBlock->setDescription(Mage::helper('core/string')->substr($product->getDescription(), 0, 255));
}
Therefore if you don't have a meta description, the description is used instead. And (at least in 1.7.0.2) it is nearly echoed "as it is":
<meta name="description" content="<?php echo htmlspecialchars($this->getDescription()) ?>" />
So to solve your problem, I think the easiest is, if you add a meta description. Or you can change the template to strip the tags.
다른 팁
The meta-description (and meta-keywords) values are not processed before displayed in the page. Anything you enter there will be shown "as it is".
On the other hand, I see no reason as to why html tags should entered in the "meta" fields.