Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON-LD and Microdata on the same page?

I have both Micro Data and JSON-LD on my e-commerce product pages, describing the same thing (products in my case). For reasons beyond the scope of this question, I cannot remove either of the two formats. I am wondering:

  1. Is this a problem for Google? The structured data testing tool does display two items (products) instead of one.

  2. If one property, let's say the name of the product, is slightly different between the two formats, would any of the two formats, for example, JSON-LD take priority?

like image 552
Milen Kovachev Avatar asked Dec 08 '16 08:12

Milen Kovachev


People also ask

Should I use microdata or JSON-LD?

With JSON-LD, a JavaScript object is inserted into the HTML of your page to define data, whereas microdata uses HTML tags and attributes to define data. In its structured data guidelines, Google states that it recommends JSON-LD over microdata for web content.

Where should Ld JSON be placed?

Google recommends adding JSON-LD to the <head> section of the HTML document; however, it's okay if the JSON-LD is within the <body> section. Google can also grasp dynamically generated tags in the DOM.

Why should you have microdata on your site?

The microdata tags can help your site get indexed and ranked more accurately, and the resulting rich snippets can help your site stand out from others on the results page and drive more traffic to you.

Does JSON-LD help SEO?

Using JSON-LD markup helps to improve a website's representation in search engine positioning. JSON-LD markup allows you to markup data for the knowledge graph rich snippets, display site search in SERPs and markup different types of events.


1 Answers

The problem is that a consumer would think that different things are described (or more accurately: the consumer wouldn’t know if the things are the same or not).

There is a way to prevent this¹: give each thing a URI, and in case the things are the same, the same URI.

This can be done with @id in JSON-LD, and with itemid in Microdata.

So a simple case could be:

<!-- markup on the product page, 
     so the fragment "#this" results in an absolute URI like 
     "http://example.com/products/foo#this" -->

<!-- JSON-LD -->
<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Product",
  "@id": "#this",
  "name": "Foo"
}
</script>

<!-- Microdata -->    
<article itemscope itemtype="http://schema.org/Product" itemid="#this">
  <h1 itemprop="name">Foo</h1>
</article>

In case a property like name has different values, the obvious way a consumer could handle this is to give the thing multiple names. For a feature where the consumer needs exactly one name (e.g., in a rich result), it’s not defined which of the name values will be used. If the consumer is a search engine, it will likely use its already existing proprietary algorithms to handle such cases.


¹ Of course it’s not clear if/how all the various consumers support it. But it’s the correct way to do this, and it’s the only explicit way to do this. Implicit ways include hoping that a consumer understands that identical values for typically (but not necessarily) unique properties (e.g., url, email, productID, etc.) mean that the things are the same. But such an implicit way can of course be used together with the explicit one.

like image 68
unor Avatar answered Sep 27 '22 16:09

unor