关于mainEntityOfPage
是什么以及如何使用它,我已经阅读了几个答案,每个答案都比上一个更令人困惑。
所以我的问题很具体;我有一个包含博客部分的网站。在博客详细信息页面上,我要使用JSON-LD格式的结构化数据。
我的问题:我的mainEntityOfPage
是WebPage
还是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>
我正在考虑mainEntityOfPage
是BlogPosting
,所以第一个例子是吗?还是我还是错了?
答案 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.