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

4

我看到关于这个主题的另一个类似问题,但没有被接受的正确答案或示例。 这个元素的格式应该是什么样的? 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>

将提到的问题链接起来会很有用。它是 如何使用 JSON-LD 创建 SiteNavigationElement? 吗? - unor
1个回答

9
我认为你的网站导航元素应该包含在列表项中,或者作为独立的项目包含在其中。
例如,作为列表的一部分:
<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>

然而,仅仅因为你可以这样做,并不意味着你应该这样做。请查看这个相关的答案

我认为你的SiteNavigationElement URL应该是当前页面上元素本身的链接(而不是它们导航到的页面),这通常是不存在的。


1
这不可能是正确的,因为页面上不应该有超过1个“ItemList”,因此在导航中使用它会防止其出现在其他任何地方。 - bysanchy

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接