繁体   English   中英

HTML5微数据 - itemref到多个itemscope的

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

是否可以使用itemref链接到多个itemscope。 这是场景:

我在一个页面上有一些博客帖子,每个博客帖子都有相同的人员和组织元信息。 而不是在每篇博文中包含人员和组织的所有元信息,而是可以引用该信息吗? 我可以用一个参考文献来做,例如人:

<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>

但是无法用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>

要么:

<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>

通过https://developers.google.com/structured-data/testing-tool/运行这两项操作都会出错。 尽管至少第三个示例显示正在进行组织引用。

itemref属性可以采用多个值,以空格分隔。

而不是

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

采用

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

¹引用。 WHATWG规格: itemref / W3C注意: itemref

暂无
暂无

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

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