简体   繁体   English

HTML5微数据 - itemref到多个itemscope的

[英]HTML5 Microdata - itemref to multiple itemscope's

Is it possible to use itemref to link to more than 1 itemscope. 是否可以使用itemref链接到多个itemscope。 Here's the scenario: 这是场景:

I have a few blog posts on a page, each blog post has the same person and organization meta info. 我在一个页面上有一些博客帖子,每个博客帖子都有相同的人员和组织元信息。 Rather than including all the meta info for the person and the organisation in each blog post, can that info be referenced to instead? 而不是在每篇博文中包含人员和组织的所有元信息,而是可以引用该信息吗? I can do it with one reference, eg person: 我可以用一个参考文献来做,例如人:

<div id="person" itemscope itemprop="author" itemtype="http://schema.org/Person">
  <span itemprop="name">Joe Blogs</span>
</div>

<article itemscope itemtype="http://schema.org/BlogPosting" itemref="person">
  <a href="/" itemprop="mainEntityOfPage"><h1 itemprop="headline">Title</h1></a>
  <time datetime="2016-01-01 12:00:00" itemprop="datePublished">1st Jan</time>
  <time datetime="2016-01-02 12:00:00" itemprop="dateModified">2nd Jan</time>

  <div itemprop="image" itemscope itemtype="https://schema.org/ImageObject">
    <img src="image.jpg">
    <meta itemprop="url" content="http://example.com/image.jpg">
    <meta itemprop="width" content="400">
    <meta itemprop="height" content="400">
  </div>

  <div itemscope itemprop="publisher" itemtype="http://schema.org/Organization">
    <span itemprop="name">Organization</span>
    <div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject">
      <meta itemprop="url" content="http://example.com/image.jpg">
      <meta itemprop="width" content="600">
      <meta itemprop="height" content="60">
    </div>
  </div>
</article>

<article itemscope itemtype="http://schema.org/BlogPosting" itemref="person">
  <a href="/" itemprop="mainEntityOfPage"><h1 itemprop="headline">Title</h1></a>
  <time datetime="2016-01-01 12:00:00" itemprop="datePublished">1st Jan</time>
  <time datetime="2016-01-02 12:00:00" itemprop="dateModified">2nd Jan</time>

  <div itemprop="image" itemscope itemtype="https://schema.org/ImageObject">
    <img src="image.jpg">
    <meta itemprop="url" content="http://example.com/image.jpg">
    <meta itemprop="width" content="400">
    <meta itemprop="height" content="400">
  </div>

  <div itemscope itemprop="publisher" itemtype="http://schema.org/Organization">
    <span itemprop="name">Organization</span>
    <div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject">
      <meta itemprop="url" content="http://example.com/image.jpg">
      <meta itemprop="width" content="600">
      <meta itemprop="height" content="60">
    </div>
  </div>
</article>

But haven't been able to do it with 2 references: 但是无法用2个参考文献做到这一点:

<div id="person" itemscope itemprop="author" itemtype="http://schema.org/Person">
  <span itemprop="name">Joe Blogs</span>
</div>

<div id="organization" itemscope itemprop="publisher" itemtype="http://schema.org/Organization">
  <span itemprop="name">Organization</span>
  <div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject">
    <meta itemprop="url" content="http://example.com/image.jpg">
    <meta itemprop="width" content="600">
    <meta itemprop="height" content="60">
  </div>
</div>

<article itemscope itemtype="http://schema.org/BlogPosting" itemref="person" itemref="organization">
  <a href="/" itemprop="mainEntityOfPage"><h1 itemprop="headline">Title</h1></a>
  <time datetime="2016-01-01 12:00:00" itemprop="datePublished">1st Jan</time>
  <time datetime="2016-01-02 12:00:00" itemprop="dateModified">2nd Jan</time>

  <div itemprop="image" itemscope itemtype="https://schema.org/ImageObject">
    <img src="image.jpg">
    <meta itemprop="url" content="http://example.com/image.jpg">
    <meta itemprop="width" content="400">
    <meta itemprop="height" content="400">
  </div>
</article>

<article itemscope itemtype="http://schema.org/BlogPosting" itemref="person" itemref="organization">
  <a href="/" itemprop="mainEntityOfPage"><h1 itemprop="headline">Title</h1></a>
  <time datetime="2016-01-01 12:00:00" itemprop="datePublished">1st Jan</time>
  <time datetime="2016-01-02 12:00:00" itemprop="dateModified">2nd Jan</time>

  <div itemprop="image" itemscope itemtype="https://schema.org/ImageObject">
    <img src="image.jpg">
    <meta itemprop="url" content="http://example.com/image.jpg">
    <meta itemprop="width" content="400">
    <meta itemprop="height" content="400">
  </div>
</article>

Or: 要么:

<div id="person" itemscope itemprop="author" itemtype="http://schema.org/Person">
  <span itemprop="name">Joe Blogs</span>
</div>

<div id="organization" itemscope itemprop="publisher" itemtype="http://schema.org/Organization">
  <span itemprop="name">Organization</span>
  <div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject">
    <meta itemprop="url" content="http://example.com/image.jpg">
    <meta itemprop="width" content="600">
    <meta itemprop="height" content="60">
  </div>
</div>

<article itemscope itemtype="http://schema.org/BlogPosting" itemref="person">
  <a href="/" itemprop="mainEntityOfPage"><h1 itemprop="headline">Title</h1></a>
  <time datetime="2016-01-01 12:00:00" itemprop="datePublished">1st Jan</time>
  <time datetime="2016-01-02 12:00:00" itemprop="dateModified">2nd Jan</time>

  <div itemprop="image" itemscope itemtype="https://schema.org/ImageObject">
    <img src="image.jpg">
    <meta itemprop="url" content="http://example.com/image.jpg">
    <meta itemprop="width" content="400">
    <meta itemprop="height" content="400">
  </div>

  <meta itemref="organization" itemscope itemprop="publisher" itemtype="http://schema.org/Organization">
</article>

<article itemscope itemtype="http://schema.org/BlogPosting" itemref="person">
  <a href="/" itemprop="mainEntityOfPage"><h1 itemprop="headline">Title</h1></a>
  <time datetime="2016-01-01 12:00:00" itemprop="datePublished">1st Jan</time>
  <time datetime="2016-01-02 12:00:00" itemprop="dateModified">2nd Jan</time>

  <div itemprop="image" itemscope itemtype="https://schema.org/ImageObject">
    <img src="image.jpg">
    <meta itemprop="url" content="http://example.com/image.jpg">
    <meta itemprop="width" content="400">
    <meta itemprop="height" content="400">
  </div>

  <meta itemref="organization" itemscope itemprop="publisher" itemtype="http://schema.org/Organization">
</article>

Running both of these through https://developers.google.com/structured-data/testing-tool/ gives errors. 通过https://developers.google.com/structured-data/testing-tool/运行这两项操作都会出错。 Although at least the third example shows that the organization reference is being made. 尽管至少第三个示例显示正在进行组织引用。

The itemref attribute can¹ take several values, separated by space. itemref属性可以采用多个值,以空格分隔。

So instead of 而不是

<article itemscope itemtype="http://schema.org/BlogPosting" itemref="person" itemref="organization">

use 采用

<article itemscope itemtype="http://schema.org/BlogPosting" itemref="person organization">

¹ ref. ¹引用。 WHATWG spec: itemref / W3C Note: itemref WHATWG规格: itemref / W3C注意: itemref

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM