为何我的Schema服务未被正确识别?请求验证定价表Microdata
Schema微数据验证:带minPrice的Service未被正确识别
我不确定我的定价表是否已按照Schema/Microdata规范正确配置,能否协助验证?Schema官方验证工具未检测到任何错误或警告,但在验证过程中,由于使用了PriceSpecification和minPrice,‘Hair colour’服务未被正确识别为Service类型。
原代码如下:
<table> <thead> <tr> <th scope="col">Treatment</th> <th scope="col">Price</th> </tr> </thead> <tbody> <tr> <th colspan="2" scope="col">Cuts and hair colours</th> </tr> <tr itemscope itemtype="https://schema.org/Service"> <td itemprop="name">Consultation<br /> <small>when you need ideas</small></td> <td itemprop="offers" itemscope itemtype="https://schema.org/Offer"> <span itemprop="price" content="0">Free</span> <meta itemprop="priceCurrency" content="DKK" /> </td> </tr> <tr itemscope itemtype="https://schema.org/Service"> <td itemprop="name">Lady haircut<br /> <small>including wash</small></td> <td itemprop="offers" itemscope itemtype="https://schema.org/Offer"> <span itemprop="price" content="660">660</span> <span itemprop="priceCurrency" content="DKK">kr.</span> </td> </tr> <tr itemscope itemtype="https://schema.org/Service"> <td itemprop="name">Hair colour<br /> <small>including wash</small></td> <td itemprop="offers" itemscope itemtype="https://schema.org/Offer"> <div itemscope itemtype="https://schema.org/PriceSpecification"> <span itemprop="minPrice" content="1650">from 1.650</span> <span itemprop="priceCurrency" content="DKK">kr.</span> </div> </td> </tr> </tbody> </table>
问题原因
问题出在Offer与PriceSpecification的关联逻辑上。按照Schema规范,Offer需要通过priceSpecification属性来关联PriceSpecification对象,原代码中仅嵌套了PriceSpecification但未指定该 itemprop,导致两者的关联关系未被验证工具识别,进而影响了上层Service类型的判定。
修正后的代码
<table> <thead> <tr> <th scope="col">Treatment</th> <th scope="col">Price</th> </tr> </thead> <tbody> <tr> <th colspan="2" scope="col">Cuts and hair colours</th> </tr> <tr itemscope itemtype="https://schema.org/Service"> <td itemprop="name">Consultation<br /> <small>when you need ideas</small></td> <td itemprop="offers" itemscope itemtype="https://schema.org/Offer"> <span itemprop="price" content="0">Free</span> <meta itemprop="priceCurrency" content="DKK" /> </td> </tr> <tr itemscope itemtype="https://schema.org/Service"> <td itemprop="name">Lady haircut<br /> <small>including wash</small></td> <td itemprop="offers" itemscope itemtype="https://schema.org/Offer"> <span itemprop="price" content="660">660</span> <meta itemprop="priceCurrency" content="DKK" /> <span>kr.</span> </td> </tr> <tr itemscope itemtype="https://schema.org/Service"> <td itemprop="name">Hair colour<br /> <small>including wash</small></td> <td itemprop="offers" itemscope itemtype="https://schema.org/Offer"> <div itemprop="priceSpecification" itemscope itemtype="https://schema.org/PriceSpecification"> <span itemprop="minPrice" content="1650">from 1.650</span> <meta itemprop="priceCurrency" content="DKK" /> <span>kr.</span> </div> </td> </tr> </tbody> </table>
修正说明
- 在PriceSpecification的外层div添加
itemprop="priceSpecification",明确它是Offer的属性,建立起两者的关联关系,让验证工具能正确识别Service结构 - 将所有priceCurrency的展示与Schema内容分离:用meta标签存储规范的货币代码(DKK),页面显示的"kr."单独用span标签,避免内容混淆,同时符合Schema规范
这样修改后,验证工具就能正确识别‘Hair colour’对应的Service类型,且无规范错误。
内容的提问来源于stack exchange,提问作者mikailyilmaz3
相关产品推荐
相关产品推荐

