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

Html 使用微数据时在父项范围和子项范围之间共享属性,html,schema.org,microdata,google-rich-snippets,Html,Schema.org,Microdata,Google Rich Snippets,我正在使用微数据来标记一篇博客文章。我遇到了一个问题,我无法通过谷歌找到解决方案 简而言之,我也希望使用嵌套itemscope中为父itemscope指定的属性 我已经将代码简化为下面的示例,我想使用作者图像作为博客文章的图像 <article itemscope itemtype="http://schema.org/BlogPosting"> <meta itemprop="dateModified" content="2016-02-25" /> <d

我正在使用微数据来标记一篇博客文章。我遇到了一个问题,我无法通过谷歌找到解决方案

简而言之,我也希望使用嵌套itemscope中为父itemscope指定的属性

我已经将代码简化为下面的示例,我想使用作者图像作为博客文章的图像

<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”下的
,它执行我需要的操作,但会产生一个新错误:

属性itemtype的值无效


我用它来验证微观数据。

这里涉及两个独立的问题

微数据解决方案 要将
image
属性从
Person
项目添加到
BlogPosting
项目,您可以使用
itemref
属性:

  • image
    属性(在
    Person
    中)指定
    id
    属性
  • 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>
    
    可以使用URL或
    ImageObject
    项作为值,但Google希望看到
    ImageObject
    以获取丰富的代码片段


    (就像您使用
    徽标
    属性所做的那样。)

    请注意,您的
    span
    元素(使用
    datePublished
    属性)无效,因为它是。您应该使用
    time
    元素(及其
    datetime
    属性)。您好,感谢您的清晰、简洁和信息丰富的回答。我已经切换到另一个项目好几天了,但一旦我能够测试它,我就会接受答案。我希望现在可以投票表决。非常感谢。工作完全按照你的建议进行,也谢谢你的一般建议。