2

Now, after reading several articles online, I finally got confused. I have a main navigation with multiple sub categories. Found 2 examples then I stopped b/c I am confused.

Example 1:

{
      "@context":"http://schema.org",
      "@type":"ItemList",
      "itemListElement":[
        {
          "@type": "SiteNavigationElement",
          "position": 1,
          "name": "Sign Up",
          "description": "Create your example profile.",
          "url":"https://example.com"
        },
        {
          "@type": "SiteNavigationElement",
          "position": 2,
          "name": "About us",
          "description": "Read more about example company",
          "url":"https://example.com/about"
        },
        {......

Example 2:

{
        "@context": "https://schema.org",
        "@graph": 
        [
          {
              "@context": "https://schema.org",
              "@type":"SiteNavigationElement",
              "@id":"#table-of-contents",
              "name": "Section 1",
              "url": "https://www.example.com/page#toc-1"
          },
          {
              "@context": "https://schema.org",
              "@type":"SiteNavigationElement",
              "@id":"#table-of-contents",
              "name": "Section 2",
              "url": "https://www.example.com/page#toc-2"
          },
          {....

What is the difference between these 2 usage? They are both valid but couldn't decide which one to adopt.

unor
  • 92,415
  • 26
  • 211
  • 360

1 Answers1

3

Example 1 consists of an ItemList with two SiteNavigationElement elements.
Example 2 consists of two SiteNavigationElement elements (and both elements are the same, because they have the same @id value).

I would say neither is correct for what you intend to convey.

The SiteNavigationElement type represents the whole navigation, not a single navigation link (most likely).

{
  "@context": "http://schema.org",
  "@type": "SiteNavigationElement",
  "name": "Main navigation"
}

If you want to provide data about each navigation link, you could consider using an ItemList in addition, where each link could be a WebPage (specified with itemListElement).

{
  "@context":"http://schema.org",
  "@type": ["SiteNavigationElement", "ItemList"],
  "name": "Main navigation",
  "itemListElement": [
    {"@type": "WebPage"},
    {"@type": "WebPage"},
    {"@type": "WebPage"}
  ]
}
unor
  • 92,415
  • 26
  • 211
  • 360
  • There shouldn't be more than 1 "ItemList" on the same page thus having it on the navigation prevents it anywhere else on the page. I don't think this is the correct structure. – bysanchy Mar 17 '19 at 12:30
  • 1
    @sanchy: Schema.org has no such requirement. There are plenty use cases where multiple `ItemList` items are needed. Maybe you refer to an error in Google’s SDTT, but note that this is not a Schema.org validator -- these errors refer to Google-specific features (if you can’t meet Google’s requirements, you don’t get the feature -- nothing else happens). – unor Mar 17 '19 at 22:29
  • For anyone looking for an answer, I want to highlight this -> "if you can’t meet Google’s requirements, you don’t get the feature". Structured data testing tool says explicitly that you shouldn't have more than 1 ItemList on the same page. That means, if you use it for your main navigation, you don't use it for anything else on any page on your whole site. – bysanchy Mar 19 '19 at 04:00