navigation - JSON-LD 中 SiteNavigationElement 的正确语法和用法

标签 navigation schema.org json-ld

现在,在网上看了几篇文章后,我终于搞糊涂了。我有一个包含多个子类别的主导航。找到了 2 个例子,然后我就停下来了,因为我很困惑。

示例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"
        },
        {......

示例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"
          },
          {....

这两种用法有什么区别?它们都是有效的,但无法决定采用哪一个。

最佳答案

示例 1 由一个 ItemList 和两个 SiteNavigationElement 元素组成。
示例 2 由两个 SiteNavigationElement 元素组成(这两个元素相同,因为它们具有相同的 @id 值)。

我想说这两种都不适合您想要传达的内容。

SiteNavigationElement 类型表示整个导航,而不是单个导航链接 ( most likely )。

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

如果您想提供有关每个导航链接的数据,您可以考虑使用 ItemList此外,每个链接可以是 WebPage (用 itemListElement 指定)。

{
  "@context":"http://schema.org",
  "@type": ["SiteNavigationElement", "ItemList"],
  "name": "Main navigation",
  "itemListElement": [
    {"@type": "WebPage"},
    {"@type": "WebPage"},
    {"@type": "WebPage"}
  ]
}

关于navigation - JSON-LD 中 SiteNavigationElement 的正确语法和用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52762018/

相关文章:

css - 如何在调整寡妇大小时锁定导航位置?

html - Google Article Rich Snippet 的 'mainEntityOfPage' 微数据标记

seo - 一个页面上可以有多个相同 Schema.org 类型的项目吗?

JSON-LD 自定义上下文

JSON-LD无法在@context中定义多个节点类型

html - Bootstrap : Responsive navigation bar that fits in every browser

serialization - 使用 MvvmCross ShowViewModel 传递复杂的导航参数

android - 如何使用抽屉导航调用我的 Activity 之一?

schema.org - 使用 2 'mainEntity' 和 JSON-LD

java - JSONLD : How to convert a json into JsonLD?