3

Will this structure be problematic?

<script type="application/ld+json">
{  
   "@context":"http://schema.org",
   "@type":"WebPage",
   "name":"Postcards",
   "url":"https://local.mysite.com/postcards.html",
   "breadcrumb":{  
      "@type":"BreadcrumbList",
      "itemListElement":[  
         {  
            "@type":"ListItem",
            "position":1,
            "item":{  
               "@id":"https://local.mysite.com",
               "name":"My Site"
            }
         },
         {  
            "@type":"ListItem",
            "position":2,
            "item":{  
               "@id":"https://local.mysite.com/postcards.html",
               "name":"Postcards"
            }
         }
      ]
   },
   "mainEntity":{  
      "@type":"WebPageElement",
      "offers":{  
         "@type":"Offer",
         "itemOffered":[  
            {  
               "@type":"Product",
               "name":"Christmas Postcards",
               "url":"https://local.mysite.com/christmas-postcards.html"
            },
            {  
               "@type":"Product",
               "name":"Getaway Postcards",
               "url":"https://local.mysite.com/getaway-postcards.html"
            }
         ]
      }
   }
}</script>

<script type="application/ld+json">
{  
   "@context":"http://schema.org",
   "@type":"WebPage",
   "name":"Postcards",
   "url":"https://local.mysite.com/postcards.html",
   "breadcrumb":{  
      "@type":"BreadcrumbList",
      "itemListElement":[  
         {  
            "@type":"ListItem",
            "position":1,
            "item":{  
               "@id":"https://local.mysite.com",
               "name":"My Site"
            }
         },
         {  
            "@type":"ListItem",
            "position":2,
            "item":{  
               "@id":"https://local.mysite.com/postcards.html",
               "name":"Postcards"
            }
         }
      ]
   },
   "mainEntity":{  
      "@type":"WebPageElement",
      "offers":{  
         "@type":"Offer",
         "itemOffered":[  
            {  
               "@type":"Product",
               "name":"Mini Postcards",
               "url":"https://local.mysite.com/mini-postcards.html"
            },
            {  
               "@type":"Product",
               "name":"Summer Postcards",
               "url":"https://local.mysite.com/summer-postcards.html"
            }
         ]
      }
   }
}</script>

The reason there could be "duplicate" markup like this for a single category page is that the page may use multiple product templates.

In the current implementation, the markup is dynamically constructed in the product template. For example, if there are two product templates for a single Category Page, the markup will be reconstructed twice, but containing different WebPageElement.

Will this yield bad results? I checked in Google's testing tool and it didn't give me any errors or warnings.

unor
  • 92,415
  • 26
  • 211
  • 360
herondale
  • 729
  • 10
  • 27
  • About your use of Schema.org: 1) I wouldn’t use `WebPageElement` at all here. You could directly provide the `Offer` nodes as value of `mainEntity`. 2) Unless a single offer really consists of two products (i.e., you can get them only together), each `Product` should get its own `Offer`. This question isn’t the right place to discuss this, though, so if you are interested in it, you could ask on [codereview.se]. – unor Jan 31 '18 at 00:46

1 Answers1

2

Multiple nodes, same entity

If you have multiple nodes that represent the same entity on a page, the best practice is to give these nodes the same URI as identifier.

With JSON-LD, you can provide identifiers with @id.

So

  • both of your WebPage items could get "@id": "" (for the current URL; preferably specify your canonical URL here),
  • both of your BreadcrumbList items could get "@id": "#breadcrumbs",
  • both of your ListItem-1 items could get "@id": "#breadcrumbs-1", and
  • both of your ListItem-2 items could get "@id": "#breadcrumbs-2".

That way, Google’s SDTT will display each of these items only once, because it now knows that they are about the same entity.

Referencing nodes instead of duplicating them

@id also allows you to reference nodes instead of embedding them (and thereby duplicating their data). See an example.

In your case this would have the advantage that you don’t have to duplicate the WebPage/BreadcrumbList/ListItem nodes to begin with. You would specify these nodes once, and each product template would then outpout only the Offer/Product nodes. These nodes could include (reverse) references to the WebPage/etc. (might be easier for you to implement), or the WebPage/etc. could reference these nodes.

unor
  • 92,415
  • 26
  • 211
  • 360
  • Thanks! I just have one question then, so will having multiple nodes for the same entity affect the page's performance in SERP? – herondale Feb 02 '18 at 23:53
  • @herondale: SEO is off-topic on Stack Overflow (it’s on-topic on [webmasters.se], e.g., see [Schema.org and SEO](https://webmasters.stackexchange.com/q/108333/17633)). If you mean rich results with "performance in SERP", there should be no reason to assume this. Either a search engine recognizes that these are same entities, or not; either a search engine does something with multiple or with one entity etc. – unor Feb 04 '18 at 03:06