结构化数据(微数据)和嵌入式项目 [英] Structured data (microdata) and embedded items

查看:85
本文介绍了结构化数据(微数据)和嵌入式项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Schema.org中使用Microdata来定义网页的主要内容,所以我做了这样的事情:

I want to use Microdata with Schema.org to define the main content of my webpage, so I did something like this:

<body itemscope="itemscope" itemtype="http://schema.org/WebPage">
  ...
  <div itemprop="mainContentOfPage" itemscope="itemscope" itemtype="http://schema.org/WebPageElement">

    <div itemprop="breadcrumb" itemscope="itemscope" itemtype="http://schema.org/BreadcrumbList">...</div>

  </div>
  ...
</body>

问题是,当我在Google结构化数据测试工具下检查架构时,收到错误消息:

The problem is that when I check the schema under the Google Structured Data Testing Tool I receive the error:

对于类型为WebPageElement的对象,Google无法识别属性面包屑".

The property breadcrumb is not recognised by Google for an object of type WebPageElement.

那么怎么说breadcrumbWebPageitemscope相关而不是与WebPageElementitemscope相关?由于设计原因,我无法从WebPageElement div中获得breadcrumb.

So how to say that the breadcrumb is related to the itemscope of the WebPage and not to the itemscope of the WebPageElement? Because of the design, I can not get the breadcrumb out of the WebPageElement div.

顺便说一句,在这里我以breadcrumb为例,它可以是任何其他属性,例如copyrightHolderheadline.

By the ways, I use breadcrumb just as an example here—it can be any other property, like copyrightHolder or headline, for example.

推荐答案

有一个丑陋的解决方案:添加一个具有itemscope(但没有itemtype)作为breadcrumbs属性父级的div,并使用itemrefbreadcrumb属性添加到WebPage项目.

There is an ugly solutions for this: add a div with an itemscope (but without itemtype) as parent for the breadcrumbs property, and use itemref to add the breadcrumb property to the WebPage item.

<body itemscope="itemscope" itemtype="http://schema.org/WebPage" itemref="breadcrumbs">

  <div itemprop="mainContentOfPage" itemscope="itemscope" itemtype="http://schema.org/WebPageElement">

    <div itemscope>
      <div itemprop="breadcrumb" itemscope="itemscope" itemtype="http://schema.org/BreadcrumbList" id="breadcrumbs">…</div>
    </div>

  </div>

</body>

我不建议这样做(但这是有效的微数据).您确实应该尝试更改标记结构,这样就不必像这样嵌套它了.

I don’t recommend this (but it’s valid Microdata). You should really try to change the markup structure so that you don’t have to nest it like that.

话虽如此,您可能想使用 mainEntity / mainContentOfPage ,因为mainContentOfPage仅用于WebPageElement个项目,因此它不是很有用.

Having said that, you might want to use mainEntity/mainEntityOfPage instead of mainContentOfPage, because mainContentOfPage is only for WebPageElement items, which makes it not very useful.

这篇关于结构化数据(微数据)和嵌入式项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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