微数据 schema.org:如何将架构混合在一起



你好,我有一个页面(http://schema.org/WebPage(包含评论(http://schema.org/Review(

问题是:

  • 如何处理重复内容?
  • 使元素属于两个或多个范围是否正确?
  • 如何做到这一点,重复文本两次?
  • 或者我应该避免多次引用?

例:

<html itemscope itemtype="http://schema.org/WebPage">
    <meta name="description" content="_________" itemprop="description">
    ...
    <div itemscope itemtype="http://schema.org/Review">
        <div itemprop="description">_________</div>
    </div>
    ...
</html>

描述属于评论和网页,所以...在这种情况下我应该写什么?

(注意:在前面的示例中,字符串"__"是相同的文本段落,重复两次(


编辑:

这可以是一个解决方案吗?(HTML5 规范没有讨论这个,但定义了 itemref 属性(

<html itemscope itemtype="http://schema.org/WebPage" id="WEBPAGE">
    ...
    <div itemscope itemtype="http://schema.org/Review" id="REVIEW">
        <div itemprop="description" itemref="WEBPAGE REVIEW">_________</div>
    </div>
    ...
</html>

随意改进问题!

快速回答

  • 如何处理重复内容?
    • 使用属性项引用
  • 使元素属于两个或多个范围是否正确?
    • 是的,这就是您使用itemref的目的
  • 如何做到这一点,重复文本两次?
    • 不,您只需要引用元素
  • 或者我应该避免多次引用?
    • 我看不出您不想使用多个引用的任何理由
<小时 />

一些例子

通过包装包含

使用 itemref 属性时,会将引用元素中包含的所有属性包含在不同的范围内。

<body itemscope itemtype="http://schema.org/WebPage" itemref="wrapper">
    ...
    <div itemscope itemtype="http://schema.org/Review">
        ...
        <div id="wrapper">
            <div itemprop="description">_________</div>
            <div itemprop="some-other-property">_________</div>
        </div>
        ...
    </div>
    ...
</body>

通过包装包含 - 一个不同的示例

假设您有一个产品,在范围之外有几个不同的优惠。

<div itemscope itemtype="http://schema.org/Product" itemref="wrapper">
    ...
</div>
<div id="wrapper">
    <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
        ...
    </div>
    <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
        ...
    </div>
    <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
        ...
    </div>
</div>

包含特定属性

您可能只希望在范围之外包含一个特定属性,为此,我们可以简单地直接在目标元素上设置 id,并指定 itemprop。

<body itemscope itemtype="http://schema.org/WebPage" itemref="target">
    ...
    <div itemscope itemtype="http://schema.org/Review">
        <div id="target" itemprop="description">_________</div>
    </div>
    ...
</body>

多个引用

也许包装器不适用,那么您可以使用多个引用。您只需通过空间将它们分开即可。

<body itemscope itemtype="http://schema.org/WebPage" itemref="desc name">
    ...
    <div itemscope itemtype="http://schema.org/Review">
        <div id="desc" itemprop="description">_________</div>
        <div id="name" itemprop="name">_________</div>
    </div>
    ...
</body>
<小时 />

另请参阅页面以获取其他一些解释和示例:
http://www.w3.org/TR/2011/WD-microdata-20110405/http://www.whatwg.org/specs/web-apps/current-work/multipage/microdata.html

相关内容

最新更新