【问题标题】:What is the correct use of mainEntityOfPage schemamainEntityOfPage 模式的正确用法是什么
【发布时间】:2023-03-21 07:35:02
【问题描述】:

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

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

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

【问题讨论】:

    标签: schema.org structured-data


    【解决方案1】:

    不,该值应该是专用于ArticleWebPage。这两个项目通常具有相同的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 时,您只需切换主语和宾语。

    【讨论】:

    • 在您提供的第一个代码 sn-p 中,如果是叶子,是否需要“@id”?
    • @Ethan:从来不需要。为每个项目提供@id“只是”一个好习惯,因为它允许其他人对此项目发表意见(Linked Data / Semantic Web)。
    • 感谢您的回答和链接。
    猜你喜欢
    • 2023-03-07
    • 1970-01-01
    • 2016-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-21
    • 2017-11-16
    相关资源
    最近更新 更多