将 SiteNavigationElement 架构为 JSON-LD 结构化数据

Schema SiteNavigationElement as JSON-LD Structured Data

我看过另一个关于这个主题的类似问题,但没有公认的正确答案或示例。 该元素的格式应该是什么? BreadcrumbList 有详细记录并包含列表,但不包含 SiteNavigationElement。

    <script type="application/ld+json">
    {
    "@context": "https://schema.org",
    "@type": "SiteNavigationElement",
    "@graph": [
        {
        "@type": "ListItem",
        "position": 1,
        "item": {
            "@id": "http://www.example.com/",
            "url": "http://www.example.com/",
            "name": "Home"
            }
        },
        {
        "@type": "ListItem",
        "position": 2,
        "item": {
            "@id": "http://www.example.com/contact.html",
            "url": "http://www.example.com/contact.html",
            "name": "Contact"
            }
        },
    ]
    }
    </script>

更新:

一直在尝试并想出了一些可行的方法。但它的结构是否正确?

<script type="application/ld+json">
//<![CDATA[
{
"@context": "https:\/\/schema.org\/",
"@type": "SiteNavigationElement",
"headline": "Headline for Site Navigation",
"name": [
    "Home",
    "Tours",
    "Transfers",
    "Taxis",
    "Contact"
    ],
"description": [
    "Homes Desc.",
    "Tours Desc.",
    "Transfers Desc.",
    "Taxis Desc.",
    "Contact Desc."
    ],
"url": [
    "http://www.example.com/",
    "http://www.example.com/tours/",
    "http://www.example.com/transfers/",
    "http://www.example.com/taxis/",
    "http://www.example.com/contact.html"
    ]
}
//]]>
</script>

我认为您的 SiteNavigationElements 应该包含在 ItemLists 中,或者只作为单独的项目包含。

例如作为列表的一部分:

<script type="application/ld+json">
{
  "@context":"http://schema.org",
  "@type":"ItemList",
  "itemListElement":[
    {
      "@type":"SiteNavigationElement",
      "position":1,
      "name": "Home",
      "description": "Homes Desc.",
      "url":"http://www.example.com/"
    },
    {
      "@type":"SiteNavigationElement",
      "position":2,
      "name": "Tours",
      "description": "Tours desc.",
      "url":"http://www.example.com/tours/"
    },

    ...etc

  ]
}
</script>

但是,仅仅因为您可以这样做并不意味着您应该这样做。查看 this relevant answer

我认为您的 SiteNavigationElement URL 应该用于当前页面上的元素本身(而不是它们 link 到的页面),这些通常不存在。