Why does Google Testing Tool use the “id” attribute to generate a URL for the Microdata item?

☆樱花仙子☆ 提交于 2019-11-26 17:52:04

问题


I'm using some Microdata to describe a blog post, and I'm surprised by the value return for Schema.org’s BlogPosting by the Google Developers Testing Tool.

I would have expected it to be the itemprop url, not a merge of the website URL and the item id.
Am I doing something wrong, or is it only a Google display issue?

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

Value returned by https://developers.google.com/structured-data/testing-tool/:

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

回答1:


This is strange.

It’s definitely not conforming to the Microdata Note. Apart from Microdata’s itemref attribute, HTML5’s id attribute has no special meaning in Microdata.

If Google wants to use the id value anyway, they should at least generate the URL with a fragment identifier, i.e., http://www.example.com/#foobar.

My guess is that they are (probably unintentionally) handling HTML5’s id attribute the same way as Microdata’s itemid attribute. If using itemid instead of id in your example, Google’s Testing Tool output is the same, but this time correct.



来源:https://stackoverflow.com/questions/29491507/why-does-google-testing-tool-use-the-id-attribute-to-generate-a-url-for-the-mi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!