链接微数据中的独立元素 [英] Linking independent elements in Microdata

查看:94
本文介绍了链接微数据中的独立元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个关于作者的网站。他是主要话题。在这个网站上也出现了他的书籍。

I'm creating a site about an author. He is the main-topic. On this site his written books are shown, too.

不幸的是,我找不到将这些书籍链接到主要元素的解决方案。我尝试了 itemref ,但在链接到没有 itemprop 值的'独立'元素时它不起作用(谷歌测试工具说)。以下两本书都不起作用。

Unfortunately, I can't find a solution to link these books to the main person-element. I tried itemref, but it doesn't work when linking to such 'independent' element, which has no itemprop value (says the Google testing tool). Both following "book"-cases don't work.

<div id="author" itemscope="" itemtype="http://schema.org/Person">
  <span itemprop="name">Marvin</span>
</div>

<div itemscope="" itemtype="http://schema.org/Book">
  <span itemprop="name">Nice Book</span>
  <meta itemprop="author" itemref="author" />
</div>

<div itemscope="" itemtype="http://schema.org/Book">
  <span itemprop="name">Best Book</span>
  <meta itemprop="author" itemscope="" itemtype="http://schema.org/Person" itemref="author" />
</div>

还有其他想法吗?

推荐答案

您有三种选择。

由@Dharmang描述。你给 Person 一个URI(带有 itemid 属性)并在每个中引用这个URI使用 author 属性预订

As described by @Dharmang. You give the Person a URI (with the itemid attribute) and reference this URI in each Book with the author property.

<div itemscope itemtype="http://schema.org/Person" itemid="#person-1">
</div>

<div itemscope itemtype="http://schema.org/Book">
  <link itemprop="author" href="#person-1" />
</div>

<div itemscope itemtype="http://schema.org/Book">
  <link itemprop="author" href="#person-1" />
</div>

(其他人也可以使用此URI,也想对此人说些什么,或者想要说些什么识别那个人。所以 [你的域名] / [你的路径]#person-1 然后是一个代表真人的URI,而不只是一个关于那个的页面如果该人已有这样的URI,您可能希望重复使用它而不是创建自己的URI。)

(This URI can then used by others that also want to say something about this person, or that want to identify that person. So [your-domain]/[your-path]#person-1 is then a URI that represents the actual person, not just a page about that person. If there is already such a URI for that person, you might want to reuse it instead of creating your own.)

问题:消费者支持可能不是最好的(但Google的测试工具似乎认识到它)。

Problem: Consumer support might not be the best (but Google’s testing tool seems to recognize it).

您必须将 itemprop =author添加到 item,并使用 itemref Book 引用其 id >属性。您不必为此添加 meta 元素,只需使用 itemscope 在元素上执行此操作即可。

You have to add itemprop="author" to the Person item, and reference its id from each Book with the itemref attribute. You don’t have to add a meta element for this, you simply do it on the element with the itemscope.

<div itemprop="author" itemscope itemtype="http://schema.org/Person" id="author">
</div>

<div itemscope itemtype="http://schema.org/Book" itemref="author">
</div>

<div itemscope itemtype="http://schema.org/Book" itemref="author">
</div>

问题: item不能拥有 itemscope 的父级(因为它的 author 属性将添加到它)。所以这意味着,例如,你不能使用 mainEntity 属性来表示 Person 是主要的 WebPage的主题

Problem: The Person item can’t have a parent with itemscope (because its author property would be added to it). So this means, for example, that you can’t use the mainEntity property to denote that the Person is the primary topic of the WebPage.

如果您可以在中嵌套预订项目item,你可以使用 itemprop-reverse 属性,它允许你在另一个方向使用属性:

If you can nest the Book items in the Person item, you could use the itemprop-reverse attribute, which allows you to use properties in the other direction:

<div itemscope itemtype="http://schema.org/Person">

  <div itemprop-reverse="author" itemscope itemtype="http://schema.org/Book">
  </div>

  <div itemprop-reverse="author" itemscope itemtype="http://schema.org/Book">
  </div>

</div>

(如果你不能嵌套,你仍然可以使用它带有URI值,但使用 itemid 在这种情况下可能是更好的选择。)

(If you can’t nest, you could still use it with a URI value, but using itemid in that case is probably the better choice.)

问题:此属性为不属于Microdata规范。它是在W3C的 Microdata中定义的 RDF 注意。因此消费者支持可能不太好。 Google的测试工具似乎无法识别它。

Problem: This attribute is not part of the Microdata specification. It’s defined in W3C’s Microdata to RDF Note. So consumer support might be not so good. Google’s testing tool doesn’t seem to recognize it.

这篇关于链接微数据中的独立元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆