问题原文
原帖链接 · Eaten by a Grue · CC BY-SA 4.0
I'm providing structured data on product pages of an ecommerce site using json-ld. For description, I've been including html markup exactly as it is on the page. For example:
{
"@context": "https://schema.org/",
"@type": "Product",
"name": "Test Product",
"sku": "1234567",
"mpn": "ABCDEFG",
"offers": {
"@type": "Offer",
"url": "https://example.com/test-product",
"price": 100.00,
"priceValidUntil": "2020-09-03",
"priceCurrency": "USD",
"itemCondition": "http://schema.org/NewCondition",
"availability": "http://schema.org/InStock"
},
"image": "https://example.com/image/test-product.jpg",
"description": "<div>\r\n<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>\r\n\r\n<ul>\r\n\t<li>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo</li>\r\n\t<li>Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem</li>\r\n</ul>\r\n</div>\r\n",
"brand": {
"@type": "Thing",
"name": "Test Manufacturer"
}
}
I found this question on stackoverflow.com, where the answers provided don't seem to reach any particular consensus about the matter. The docs for Job Posting explicitly state that description should be provided using html tags, while the docs for Product make no mention whatsoever of how it should be formatted.
I've read a plethora of articles on the subject and was unable to find anything authoritative about the matter. Google's structured data testing tool doesn't seem to have a problem with tags in the description, but I'm unsure if my markup is being treated as plain text in this scenario.
Are html tags in a product description allowed and/or encouraged, or should I be stripping them out and providing text content only?
已采纳解答
原帖链接 · GDVS · CC BY-SA 4.0
There's an important nuance here. With structured data for search, there are multiple layers of validity: the vocabulary (Schema.org, etc.), the syntax (RDFa, JSON-LD, etc.), and individual search engines' requirements.
The description property of Schema.org expects Text (as opposed to, say, Time or Boolean), so we can put basically anything in there and it'll be treated as plain text with no problem.
So the issue comes with whatever is consuming that data. For Google Jobs, basically the whole job advert goes into the description, so it makes sense for them to offer support for HTML so the advert is legible. But note they still only support some HTML.
So, is HTML allowed? Yes. The issue is whether it is consumed as HTML or as plain text.
For Product, there's currently no reason to include HTML in the description because no search engine is displaying that description, let alone displaying it with parsed HTML. Google may later decide to start displaying it, but they may or may not support HTML and, even if they do, may only support a small subset.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
