为什么 Google 测试工具会使用 "id" 属性为微数据项生成网址?



我正在使用一些Microdata来描述一篇博客文章,我对谷歌开发者测试工具为Schema.org的BlogPosting返回的值感到惊讶。

我本以为它是项目道具url,而不是网站URL和项目id的合并
我是做错了什么,还是只是谷歌的显示问题?

<div itemscope="itemscope"
     itemprop="blogPost"
     itemtype="http://schema.org/BlogPosting"
     id="foobar">
  <a itemprop="url" href="/realone">real</a>
</div>

返回的值https://developers.google.com/structured-data/testing-tool/:

  BlogPosting:    http://www.example.com/foobar
  url:            http://www.example.com/realone

这很奇怪。

这绝对不符合Microdata说明。除了Microdata的itemref属性外,HTML5的id属性在Microdata中没有特殊意义。

如果谷歌无论如何都想使用id值,他们至少应该生成带有片段标识符的URL,即http://www.example.com/#foobar

我的猜测是,他们(可能是无意中)以与Microdata的itemid属性相同的方式处理HTML5的id属性。如果在您的示例中使用itemid而不是id,Google的测试工具输出是相同的,但这次是正确的。

最新更新