如何正确使用mainEntityOfPage用于博客详细信息页面?

时间:2019-02-23 20:29:28

标签: blogs schema.org json-ld

关于mainEntityOfPage是什么以及如何使用它,我已经阅读了几个答案,每个答案都比上一个更令人困惑。

所以我的问题很具体;我有一个包含博客部分的网站。在博客详细信息页面上,我要使用JSON-LD格式的结构化数据。

我的问题:我的mainEntityOfPageWebPage还是BlogPosting

我应该使用这个吗?

<script type="application/ld+json">
{
    "@context": "http://schema.org",
    "@type": "WebPage",
    "mainEntityOfPage": {
        "@type": "BlogPosting",
    }
}
</script>

或者这个:

<script type="application/ld+json">
{
    "@context": "http://schema.org",
    "@type": "BlogPosting",
    "mainEntityOfPage": {
        "@type": "WebPage",
    }
}
</script>

我正在考虑mainEntityOfPageBlogPosting,所以第一个例子是吗?还是我还是错了?

1 个答案:

答案 0 :(得分:0)

The definition of mainEntityOfPage is:

Indicates a page (or other CreativeWork) for which this thing is the main entity being described.

The main entity on a blog post page is the blog post, not the page. So, the second snippet is correct:

{
  "@context": "http://schema.org",
  "@type": "BlogPosting",
  "mainEntityOfPage": {
    "@type": "WebPage"
  }
}

If you want to use the first snippet (so that WebPage is the top-level item), you have to use mainEntity instead of mainEntityOfPage:

{
  "@context": "http://schema.org",
  "@type": "WebPage",
  "mainEntity": {
    "@type": "BlogPosting"
  }
}

Note 1: mainEntity and mainEntityOfPage are inverse properties, so these two snippets mean the same.

Note 2: Maybe it helps to read it as "is the mainEntityOfPage", and "has mainEntity".

Note 3: You can use ItemPage (instead of WebPage) on the blog post pages.