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

时间:2017-06-22 20:12:38

标签: navigation schema.org 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>

1 个答案:

答案 0 :(得分:4)

我认为您的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网址应该是当前页面上的元素本身(而不是它们链接到的页面),这通常不存在。