Mic*_*yes 10 microdata schema.org
我的开发人员使用HTML表编写了一个产品列表.代码出现了这样的事情:
<table>
<tr class="name">
<td>Product Name #1</td><td>Product Name #2</td><td>Product Name #3</td>
</tr>
<tr class="price">
<td>Product Price #1</td><td>Product Price #2</td><td>Product Price #3</td>
</tr>
<tr class="brand">
<td>Product Brand #1</td><td>Product Brand #2</td><td>Product Brand #3</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
你明白了.在视觉上它看起来很完美,但是当尝试通过schema.org进行标记时,我遇到了问题,因为产品属性不存在是整齐的嵌套HTML元素,而是分布在整个表中.是否有办法使用ItemIDMicrodata属性来确保每个品牌和价格与正确的产品名称相关联?
就像是:
<tr class="name">
<td itemscope itemtype="http://www.schema.org/Product" itemID="Product1">Product Name #1</td>
<td itemscope itemtype="http://www.scema.org/Product" itemID="Product2">Product Name #2</td>
Run Code Online (Sandbox Code Playgroud)
等等等什么想法?我是否会对页面进行重新编码以使其正常工作?
是的,这itemid是正确的方法.你的例子看起来像这样:
<table>
<tr class="name">
<td itemscope itemtype="http://www.schema.org/Product" itemid="Product1">
<span itemprop="name">Product Name #1</span>
</td>
<td itemscope itemtype="http://www.schema.org/Product" itemid="Product2">
<span itemprop="name">Product Name #2</span>
</td>
</tr>
<tr class="price">
<td itemscope itemtype="http://www.schema.org/Product" itemid="Product1">
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<span itemprop="price">Product Price #1</span>
</div>
</td>
<td itemscope itemtype="http://www.schema.org/Product" itemid="Product2">
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<span itemprop="price">Product Price #2</span>
</div>
</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
通过重复使用它,itemid您告诉微数据解析器您正在讨论页面不同部分中的相同项目.
实际上,itemid这不是正确的方法.与RDF不同,微数据解析模型不会加入具有相同内容的东西itemid.
相反,您应该使用itemref属性.
例如:
<div itemscope itemtype="http://schema.org/Product" itemref="foo"></div>
<div id="foo" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<span itemprop="price">Product Price #1</span>
</div>
Run Code Online (Sandbox Code Playgroud)
除Google之外,您还可以使用https://webmaster.yandex.com/tools/microtest/测试微数据.
| 归档时间: |
|
| 查看次数: |
5188 次 |
| 最近记录: |