如何在schema.org值中使用链接文本作为值?

时间:2015-06-17 00:32:58

标签: html metadata schema.org microdata

我正在尝试使用docs微数据标记一些HTML,但是我的标记出现了问题:

这是我目前的HTML:

<div>
    <h1>
        <a href="example.com/1234">The name is here</a>
        <small>(Some extra info)</small>
    </h1>
    Tons more content about the thing
</div>

我想要做的是描述事物及其名称的存在并尝试:

<div itemscope itemtype="http://schema.org/Thing">
    <h1>
        <a href="example.com/1234" itemprop="name">The name is here</a>
        <small>(Some extra info)</small>
    </h1>
    Tons more content about the thing
</div>

但这给了我不正确的元数据:

enter image description here

<div itemscope itemtype="http://schema.org/Thing">
    <h1 itemprop="name">
        <a href="example.com/1234">The name is here</a>
        <small>(Some extra info)</small>
    </h1>
    Tons more content about the thing
</div>

但这也是错误的,因为它错误地将(Some extra info)标识为名称的一部分(它不是):

enter image description here

总之,有没有办法将itemprop应用于<a href=>链接,而不使用将URL作为属性的值?

1 个答案:

答案 0 :(得分:1)

Microdata没有提供一种方法来表示itemprop元素上的a不应将URL生成为值。

你必须添加另一个

元素
  • 是在微数据中生成字符串值的元素之一(tl;dr:不是time,而不是可以有href / {{1}的元素之一})和

  • 仅包含您希望拥有的属性值。

在您的示例中,您可以添加src元素:

span
<a href="example.com/1234"><span itemprop="name">The name is here</span></a>
相关问题