4

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?

  • A related question. Has anyone ever seen the description used? – Tony McCreath Sep 4 at 2:34
2

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.

  • Thanks for the breakdown. Previously I used microdata on the same description block by adding itemprop="description" to the enclosing element and then at some point made the transition to JSON-LD. Now I'm confused about whether not I need to alter the data that's being presented (i.e., strip out the tags) because I'm unsure if google was doing this for me and extracting only text content or if the full inner html was being consumed previously with the microdata. And this leads to the question about whether or not I am expected to strip these tags myself now that I've switched formats. – billynoah Sep 4 at 21:20
  • I'd not worry about it until there is a use case. – Tony McCreath Sep 5 at 1:28
  • @billynoah When you apply an itemprop to an element the content of that element is what is consumed, not the element itself. So Google wasn't stripping out the HTML, as such. So, yes, in this case, for your JSON implementation you'd just be providing the content of the description, not the whole HTML element. I stress "in this case" because, per my main answer, you can put HTML in there and some consumers of the data may choose to parse it. – GDav Sep 5 at 11:45
  • I still don't think I understand - what exactly is the "content"? If I apply itemprop to a <div> with a dozen other elements inside of it, isn't the content html? And in this case, is that html being treated as html, text content. or stripped of tags? – billynoah Sep 5 at 13:18
  • The content is whatever is between the tags of the element with the itemprop="description" attribute. If you've put that on, say, a <div> with a number of paragraph elements inside, then yes, the content contains HTML. That would be bad code, but nonetheless whatever is parsing the structured data will typically treat it as text although, as in the case of Google Jobs, it could choose to parse it (i.e. process the HTML and show text in paragraphs, rather than the "raw" code). – GDav Sep 6 at 19:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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