使用微数据时在父项范围和子项范围之间共享属性

Sharing properties between parent and child itemscopes when using Microdata

我正在使用 Microdata 来标记博客 post。我遇到了一个问题,我找不到 Google 的解决方案。

简而言之,我也想使用已在嵌套项目范围中为父项目范围指定的 属性。

我已将我的代码简化为以下示例,我想使用作者图片作为博客图片post。

<article itemscope itemtype="http://schema.org/BlogPosting">
  <meta itemprop="dateModified" content="2016-02-25" />
  <div itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="Test Organisation">
    <div itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
        <link itemprop="url" href="#" />
    </div>
  </div>
  <link itemprop="mainEntityOfPage" href="#" />
  <div class="heading">
    <h2 itemprop="name headline">Imported Article 1</h2>
  </div>
  <div class="author-aside" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img itemprop="image" src="#" />
    <div class="name" itemprop="name">Author Name</div>
    <div class="role" itemprop="jobTitle">Job Title</div>
  </div>
  <span itemprop="articleBody">
    <p>Body Content</p>
  </span>
  <br />
  <span content="2016-06-30" itemprop="datePublished">Thursday 30th June 2016</span></article>

我尝试使用在评论 "CODE I NOW HAVE" 下间接建议 in this question 的答案,它满足了我的需要,但产生了一个新错误:

The attribute itemtype has an invalid value.

我正在使用 this service 来验证微数据。

这里涉及到两个不同的问题。

微数据解决方案

要将 Person 项目中的 image 属性 也添加到 BlogPosting 项目中,您可以使用 itemref 属性:

  1. image 属性(在 Person 中)一个 id 属性。
  2. itemref 属性添加到具有 BlogPosting 类型的元素,引用 id 值。

示例:

<article itemscope itemtype="http://schema.org/BlogPosting" itemref="author-image">

  <div itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img itemprop="image" src="#" id="author-image" />
  </div>

</article>

Google 丰富网页摘要

的解决方案

虽然上面提到的标记是有效的微数据和 Schema.org 词汇表的适当使用,但 Google 有额外的 rules/restrictions 来获取他们的丰富网页摘要之一(或知识图谱功能)显示。

在 Schema.org 中,image property 可以有一个 URL 或一个 ImageObject 项目作为值,但是 Google 想要看到一个 ImageObject 用于他们的丰富网页摘要。

(就像你用 logo 属性 做的一样。)