mainEntityOfPage架构的正确用法是什么

问题描述 投票:1回答:1

我正在为杂志撰写结构化数据。我在条款类型下得到了这个:

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

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

schema.org structured-data
1个回答
2
投票

不,价值应该是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时,您只需切换主题和对象。

© www.soinside.com 2019 - 2024. All rights reserved.