我正在为一本杂志编写结构化数据。我在文章类型下得到了这个:
"mainEntityOfPage": {
"@type": "WebPage",
"@id": " https://www.example.com/category" //category of the article
},
我想我应该用这个来标记文章的类别。这是使用 mainEntityOfPage 的正确方法吗?
最佳答案
不,该值应该是专用于Article
的WebPage
。两个项目通常具有相同的 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
时,您只需切换主题和宾语即可。
关于schema.org - mainEntityOfPage 架构的正确使用是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52495259/