首页 > 解决方案 > 页面上的多个(相同类型)模式对象 - 任何方式为所有对象设置一个属性而不为每个对象重复它?

问题描述

我正在为发布产品买家指南的新网站设置结构化数据。这些指南将采用文章的形式,每篇大约有 10 个项目,我正在使用 ItemList 为指南中的每个产品实施 Review 模式。由于它是一篇文章,我还在每个指南上实现了文章模式,以利用 Google 丰富的文章搜索功能(如热门故事)。

我在我的文章架构中使用“作者”属性,但审阅架构最佳实践也建议使用“作者”属性。有什么方法可以从评论模式中引用或链接文章模式中的“作者”人?否则,我将不得不在每个 Review 模式中重复相同的“作者”信息,这似乎是多余的。

我尝试将 itemListElements 数组嵌套在 Article 架构中,但 Google 无法识别该格式。我还尝试将 author 属性添加到我的 ItemList 架构中,但它再次表示 Google 无法识别该架构类型的属性。我知道有标识符属性@id,但我不确定如何正确使用它或者它是否适用于我的问题。我将它添加到我的文章模式中的“作者”人,但是我如何在我的评论模式中引用它,这甚至可以解决我的问题吗?

这是我的代码。目前,我在文章模式中使用完整的作者信息,然后在我的评论模式元素中只使用名称(字符串)。正如我之前所说,我尝试过的几件事在Google 的结构化数据测试工具上产生了警告。以下是我在验证工具方面拥有的最干净的版本。

  <script type="application/ld+json">
  {
    "@context": "https://schema.org/",
    "@type": "Article",

    "mainEntityOfPage": {
                  "@type": "WebPage",
                  "@id": "https://example.com/best-large-camping-tents"
                },
    "headline": "10 Best Large Camping Tents",
    "image":{
                  "@type": "ImageObject",
                  "url": "https://example.com/public/build/images/best-large-camping-tents.jpg",
                  "height":700 ,
                  "width":1400
                },
    "datePublished": "May 23, 2019 14:57",
    "dateModified": "May 23, 2019 14:57",
    "author": {
                  "@type": "Person",
                  "@id": "https://example.com/author/phillipb/#author",
                  "name": "Phillip B",
                  "sameAs":[
                      "https://example.com/author/phillipb/",
                      "https://twitter.com/phillipb"
                      ]
                },
    "publisher": {
                  "@type": "Organization",
                  "name": "My Product Review Site",
                  "logo": {
                    "@type": "ImageObject",
                    "url": "https://example.com/public/build/images/my-site-logo.png",
                    "height":60,
                    "width":458
                  }
                },
    "description": "We found the 10 best large camping tents, perfect for the casual camper or the avid outdoorsman.",
    "aggregateRating": {
                "@type": "AggregateRating",
                "ratingValue": "88",
                "bestRating": "100",
                "worstRating": "1",
                "ratingCount": "20"
    }
  }
  </script> 
  <script type="application/ld+json">
  {
    "@context": "http://schema.org/",
    "@type": "ItemList",
    "name": "3 Best Large Camping Tents",
    "url": "https://www.example.com/best-large-camping-tents", 
    "itemListElement": [
      {
        "@type": "Product",
        "name": "ABC Camping Tent", 
        "url": "https://www.example.com/best-large-camping-tents/#abc-camping-tent",
        "description": "An affordable tent option for the casual camping hobbyist.", 
        "mainEntityOfPage": "https://amazon.com/abc-camping-tent-affiliate-link", 
        "image": { 
                "@type": "ImageObject", 
              "url": "https://example.com/public/build/images/abc-camping-tent-large.png",
              "height": 700,
              "width": 1400
        },
        "review": {
                "@type": "Review",
                "author": "Phillip B",
                "datePublished": "2019-04-01",
                "reviewRating": {
                  "@type": "Rating",
                  "bestRating": "5",
                  "ratingValue": "3",
                  "worstRating": "1"
              }
        }
      },
      {
        "@type": "Product",
        "name": "XYZ Camping Tent", 
        "url": "https://www.example.com/best-large-camping-tents/#xyz-camping-tent",
        "description": "A mid-scale camping tent big enough for the whole family.", 
        "mainEntityOfPage": "https://amazon.com/xyz-camping-tent-affiliate-link", 
        "image": { 
                "@type": "ImageObject", 
              "url": "https://example.com/public/build/images/xyz-camping-tent-large.png",
              "height": 700,
              "width": 1400
        },
        "review": {
                "@type": "Review",
                "author": "Phillip B",
                "datePublished": "2019-04-01",
                "reviewRating": {
                  "@type": "Rating",
                  "bestRating": "5",
                  "ratingValue": "4",
                  "worstRating": "1"
              }
        }
      },
      {
        "@type": "Product",
        "name": "PQR Camping Tent", 
        "url": "https://www.example.com/best-large-camping-tents/#pqr-camping-tent",
        "description": "The upper echelon of camping tents for the experiened hiker.", 
        "mainEntityOfPage": "https://amazon.com/pqr-camping-tent-affiliate-link", 
        "image": { 
                "@type": "ImageObject", 
              "url": "https://example.com/public/build/images/pqr-camping-tent-large.png",
              "height": 700,
              "width": 1400
        },
        "review": {
                "@type": "Review",
                "author": "Phillip B",
                "datePublished": "2019-04-01",
                "reviewRating": {
                  "@type": "Rating",
                  "bestRating": "5",
                  "ratingValue": "5",
                  "worstRating": "1"
              }
        }
      }
    ]
  }
  </script>

我希望必须有一种方法来指示何时在同一页面上的另一个模式中重用属性,但到目前为止我的尝试还没有奏效。一遍又一遍地重复相同的信息是唯一的选择吗?

标签: schema.orgjson-ld

解决方案


对于作者的所有后续引用,您可以使用:

"author": {"@id": "https://example.com/author/phillipb/#author"},

我不确定您标记的内容是否符合 Google 的准则。

如果文章的作者也是评论的作者,那似乎有些可疑?我敢肯定有关于这方面的指导方针,但我今天找不到。

https://developers.google.com/search/docs/guides/mark-up-listings
在标记其他页面上的项目列表时,您应该只标记 URL。

您还有两个脱节的顶级实体。产品如何与文章相关。文章有几种方法可以引用产品等实体。也许about


推荐阅读