首页 > 解决方案 > mainEntityOfPage 模式的正确用法是什么

问题描述

我正在为杂志编写结构化数据。我在文章类型下得到了这个:

"mainEntityOfPage": {
    "@type": "WebPage",
    "@id": " https://www.example.com/category" //category of the article
  },

我想我会用这个标记文章的类别。这是正确的使用方法mainEntityOfPage吗?

标签: schema.orgstructured-data

解决方案


不,该值应该是WebPage专用于Article. 这两个项目通常具有相同url但可能不同的@id值(请参阅页面的 URL 与 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,您只需切换主语和宾语。


推荐阅读