【问题标题】:How do I reference a description from multiple Schema.org Events in Microdata?如何引用 Microdata 中多个 Schema.org 事件的描述?
【发布时间】:2016-11-30 16:39:09
【问题描述】:

我的页面包含多个具有相同属性(名称、位置、描述等)的 Schema.org 事件。我已经弄清楚如何通过执行以下操作来处理位置:

<div itemscope itemtype="http://schema.org/Event">
  …
  <meta itemprop="location" itemscope itemtype="http://schema.org/Place" itemref="venue-place" />
</div>

<span id="venue-place">
  <a href="http://www.example.com/" itemprop="url">
    <span itemprop="name">Crystal Ballroom</span>
  </a>

  <span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
    <span itemprop="streetAddress">1332 W Burnside St.</span>
    <span itemprop="addressLocality">Portland</span>,
    <span itemprop="addressRegion">OR</span>
    <span itemprop="postalCode">97209</span>
  </span>
</span>

但是,对于事件的描述,我无法弄清楚如何做到这一点。我做了这样的事情,这使得谷歌结构化数据测试工具的事件中出现了一个空的描述:

<div itemscope itemtype="http://schema.org/Event">
  …
  <meta itemprop="description" itemscope itemref="event-summary" />
</div>

<div id="event-summary">
  This is the description text.
</div>

我做错了什么?

【问题讨论】:

    标签: html microdata


    【解决方案1】:

    itemref 属性允许您引用属性 (itemprop),并且必须在项目 (itemscope) 上指定这些属性。

    所以你必须

    • itemref="event-summary" 移动到Event 元素,然后
    • itemprop="description" 移动到带有描述的元素。
    <div itemscope itemtype="http://schema.org/Event" itemref="event-summary">
    </div>
    
    <div itemprop="description" id="event-summary">
    </div>
    

    您最好也对location 执行此操作,因为没有content 属性的meta 元素是无效的(但这可以通过添加一个空属性来解决),并且因为您可以保存一个那样的元素。

    <div itemscope itemtype="http://schema.org/Event" itemref="venue-place event-summary">
    </div>
    
    <div itemprop="location" itemscope itemtype="http://schema.org/Place" id="venue-place">
    </div>
    
    <div itemprop="description" id="event-summary">
    </div>
    

    (请注意,Google 的结构化数据测试工具将使用 Place 元素的 id 值来显示 @id 下的 URI。I think that’s a bug 在它们的末尾,所以不要让这让您感到困惑。如果您想要摆脱它,您可以添加一个 itemid 属性,并为该地点提供一个真实/实际的 URI。)

    【讨论】:

    • 你刚刚解决了我对这些东西的一大堆误解。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-04
    • 1970-01-01
    • 2016-03-18
    • 1970-01-01
    相关资源
    最近更新 更多