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

Bar*_*ton 3 navigation structured-data schema.org json-ld

我已经在这个问题上看到了另一个类似的问题,但是没有接受正确的答案或示例。此元素的格式应该是什么?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>
Run Code Online (Sandbox Code Playgroud)

更新:

一直在玩,并想出了一些可行的方法。但是它的结构正确吗?

<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>
Run Code Online (Sandbox Code Playgroud)

Ale*_*exG 6

我认为您的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>
Run Code Online (Sandbox Code Playgroud)

但是,仅仅因为您可以这样做并不意味着您应该这样做。查看此相关答案

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