我正在为杂志撰写结构化数据。我在条款类型下得到了这个:
"mainEntityOfPage": {
"@type": "WebPage",
"@id": " https://www.example.com/category" //category of the article
},
我以为我会用这个来标记文章的类别。这是使用mainEntityOfPage
的正确方法吗?
不,价值应该是WebPage
专用于Article
。这两个项目通常具有相同的url
,但可能具有不同的@id
值(请参阅URL of page vs. post)。
{
"@context": "http://schema.org",
"@type": "Article",
"@id": "/articles/42#this",
"url": "/articles/42",
"mainEntityOfPage": {
"@type": "ItemPage",
"@id": "/articles/42",
"url": "/articles/42"
}
}
在查看逆属性mainEntity
时,它可能会变得更清晰。您将拥有当前页面的WebPage
并提供mainEntity
属性以传达此页面上的主要实体:
{
"@context": "http://schema.org",
"@type": "ItemPage",
"mainEntity": {
"@type": "Article"
}
}
当使用mainEntityOfPage
而不是mainEntity
时,您只需切换主题和对象。