1

I want to build JSON-LD for my homepage. In my page I have:

  1. header
  2. navigation (2 series)
  3. sidebar (with 2 list of items)
  4. one list of main items
  5. footer

I try build the JSON-LD like this:

<script type="application/ld+json">
[
{
    "@context": "http://schema.org",
    "@type": "WebSite",
    .
    .
    .
},
{
    "@context": "http://schema.org",
    "@type": "WebPage",
    "mainEntity":{
         "@type": "ItemList",
          "itemListElement":[
           {
               "@type": "BlogPosting",
               .
               .// 4- one list of main items
               .
           }
           ...
           ]
    }
    .
    .
    .
}]
</script>

If my structure is true,

  1. how can I add SiteNavigationElement and sidebar content to this JSON object? Do I have to add another object or I can insert it in WebPage?

  2. I use JSON-LD. Do I need to use Microdata too? or is JSON-LD enough?

  3. I create a full sitemap-index.xml for all menu and items. Do I really need to add SiteNavigationElement (and another thing except mainEntity) in JSON-LD?

unor
  • 92,415
  • 26
  • 211
  • 360
ANDA
  • 163
  • 10

1 Answers1

1

(Everything you can do with Microdata can also be done with JSON-LD, and vice versa. So there is no need to mix. There might be consumers that support only one syntax for certain features, though.)

You can add SiteNavigationElement with the hasPart property to the WebPage:

{
  "@context": "http://schema.org",
  "@type": "WebPage",
  "hasPart": 
  {
    "@type": "SiteNavigationElement"
  }
}

But using SiteNavigationElement (and the other WebPageElement types) is typically not useful, so you might want to consider omitting it.

Community
  • 1
  • 1
unor
  • 92,415
  • 26
  • 211
  • 360
  • Is the above the same as declaring it by itself? How would you single out which element is the `SiteNavigationElement`? With the `@id` pointing to the ID of the element? Thanks for all you do, I've learned a lot from your answers. – Tom Usborne Nov 09 '18 at 17:22
  • @TomUsborne: It’s not quite the same, as my snippet conveys "There is page that has a navigation", while your alternative would convey "There is a navigation" -- but if a consumer were interested in navigations, it would likely assume for the latter that it’s the navigation for the current page. -- To convey which HTML element is used for the navigation, you could use the `xpath` and/or `cssSelector` properties (but both are in Pending currently). – unor Nov 13 '18 at 16:30