如何将SiteNavigationElement和页脚添加到JSON-LD中?

时间:2016-12-08 22:57:43

标签: schema.org json-ld

我想为我的主页构建JSON-LD。在我的页面中,我有:

  1. 导航(2系列)
  2. 侧栏(带有2个项目列表)
  3. 一个主要项目列表
  4. 页脚
  5. 我尝试像这样构建JSON-LD:

    <script type="application/ld+json">
    [
    {
        "@context": "http://schema.org",
        "@type": "WebSite",
        .
        .
        .
    },
    {
        "@context": "http://schema.org",
        "@type": "WebPage",
        "mainEntity":{
             "@type": "ItemList",
              "itemListElement":[
               {
                   "@type": "BlogPosting",
                   .
                   .// 4- one list of main items
                   .
               }
               ...
               ]
        }
        .
        .
        .
    }]
    </script>
    

    如果我的结构是真的,

    1. 如何将SiteNavigationElement和侧边栏内容添加到此JSON对象?我是否必须添加其他对象,或者我可以将其插入WebPage

    2. 我使用的是JSON-LD。我是否也需要使用Microdata?或者JSON-LD足够吗?

    3. 我为所有菜单和项目创建了一个完整的sitemap-index.xml。我是否真的需要在JSON-LD中添加SiteNavigationElement(以及除mainEntity之外的其他内容?)

1 个答案:

答案 0 :(得分:1)

(使用Microdata可以做的一切也可以用JSON-LD完成,反之亦然。所以没有必要混合。但是可能有消费者只支持某种功能的一种语法。)

您可以将SiteNavigationElement WebPage属性添加到{ "@context": "http://schema.org", "@type": "WebPage", "hasPart": { "@type": "SiteNavigationElement" } }

SiteNavigationElement

但使用{{1}}(以及其他hasPart类型)是WebPageElement,因此您可能需要考虑省略它。