itemtype
全局属性 itemtype
指定将用于定义数据结构中的 itemprop
(项目属性)的词汇表的 URL。
¥The global attribute itemtype
specifies the URL of the vocabulary that will be used to define itemprop
's (item properties) in the data structure.
itemscope
用于设置 itemtype
设置的词汇表在数据结构中的活动范围。
¥itemscope
is used to set the scope of where in the data structure the vocabulary set by itemtype
will be active.
Google 和其他主要搜索引擎支持结构化数据的 schema.org 词汇表。该词汇表定义了一组标准的类型名称和属性名称。例如,MusicEvent
表示音乐会表演,startDate
和 location
属性指定音乐会的关键细节。在这种情况下,MusicEvent
将是 itemtype
使用的 URL,startDate
和位置是 MusicEvent
定义的 itemprop
。
¥Google and other major search engines support the schema.org vocabulary for structured data. This vocabulary defines a standard set of type names and property names. For example, MusicEvent
indicates a concert performance, with startDate
and location
properties specifying the concert's key details. In this case, MusicEvent
would be the URL used by itemtype
, with startDate
and location as itemprop
's which MusicEvent
defines.
注意:有关
itemtype
属性的更多信息,请参见 https://schema.org/Thing¥Note: More about
itemtype
attributes can be found at https://schema.org/Thing
- itemtype 属性的值必须是一组无序的唯一标记,这些标记区分大小写,每个标记都是有效的绝对 URL,并且全部定义为使用相同的词汇表。该属性的值必须至少有一个标记。
- 项目类型必须全部是适用规范(例如 schema.org)中定义的类型,并且必须全部定义为使用相同的词汇表。
- itemtype 属性只能在指定了 itemscope 属性的元素上指定。
- itemid 属性只能在同时指定了 itemscope 属性和 itemtype 属性的元素上指定。它们只能在具有 itemscope 属性的元素上指定,其 itemtype 属性指定的词汇表不支持项目的全局标识符(如该词汇表规范所定义)。
- 全局标识符的确切含义由词汇表的规范确定。留给这样的规范来定义是否允许存在相同全局标识符(无论是在同一页面还是不同页面上)的多个项目,以及该词汇表的处理规则是什么,关于处理多个项目的情况 相同的 ID。
示例
表示产品的结构化数据
¥Representing structured data for a product
此示例使用微数据属性来表示产品的结构化数据,如下所示:
¥This example uses microdata attributes to represent structured data for a product, as follows:
itemscope | itemtype | 产品([https://schema.org/Product](https://schema.org/Product)) | |
itemprop | name | 执行砧 | |
itemprop | image | [https://pixabay.com/static/uploads/photo/2015/09/05/18/15/suitcase-924605_960_720.png](https://pixabay.com/static/uploads/photo/2015/09/05/18/15/suitcase-924605_960_720.png) | |
itemprop | description | Executive Anvil 比 ACME 的经典 Anvil 更光滑,非常适合寻求从高处落下的东西的商务旅行者。 | |
itemprop | mpn | 925872 | |
itemprop | 品牌[东西] | ||
itemprop | name | ACME | |
itemscope | 项目属性[项目类型] | 聚合评级[聚合评级] | |
itemprop | ratingValue | 4.4 | |
itemprop | reviewCount | 89 | |
itemprop | 优惠[优惠] | [https://schema.org/Offer](https://schema.org/Offer) | |
itemprop | priceCurrency | USD | |
itemprop | price | 119.99 | |
itemprop | priceValidUntil | 2020-11-05 | |
itemprop | itemCondition | [https://schema.org/UsedCondition](https://schema.org/UsedCondition) | |
itemprop | availability | [https://schema.org/InStock](https://schema.org/InStock) | |
itemscope | 项目属性[项目类型] | 卖家[组织] | [https://schema.org/Organization](https://schema.org/Organization) |
itemprop | name | 执行对象 |
注意:Google 的 结构化数据测试工具 是一个从 HTML 中提取微数据结构的便捷工具。在此处显示的 HTML 上尝试一下。
¥Note: A handy tool for extracting microdata structures from HTML is Google's Structured Data Testing Tool. Try it on the HTML shown here.
HTML
<div itemscope itemtype="https://schema.org/Product">
<span itemprop="brand">ACME<br /></span>
<span itemprop="name">Executive Anvil<br /></span>
<img
itemprop="image"
src="https://pixabay.com/static/uploads/photo/2015/09/05/18/15/suitcase-924605_960_720.png"
width="50"
height="50"
alt="Executive Anvil logo" /><br />
<span itemprop="description">
Sleeker than ACME's Classic Anvil, the Executive Anvil is perfect for the
business traveler looking for something to drop from a height.
<br />
</span>
Product #: <span itemprop="mpn">925872<br /></span>
<span
itemprop="aggregateRating"
itemscope
itemtype="https://schema.org/AggregateRating">
Rating: <span itemprop="ratingValue">4.4</span> stars, based on
<span itemprop="reviewCount">89 </span> reviews
</span>
<p>
<span itemprop="offers" itemscope itemtype="https://schema.org/Offer">
Regular price: $179.99<br />
<meta itemprop="priceCurrency" content="USD" />
<span itemprop="price">Sale price: $119.99<br /></span>
(Sale ends
<time itemprop="priceValidUntil" datetime="2020-11-05">5 November!</time>)
<br />
Available from:
<span
itemprop="seller"
itemscope
itemtype="https://schema.org/Organization">
<span itemprop="name">Executive Objects<br /></span>
</span>
Condition:
<link
itemprop="itemCondition"
href="https://schema.org/UsedCondition" />Previously owned, in excellent
condition<br />
<link itemprop="availability" href="https://schema.org/InStock" />In
stock! Order now!
</span>
</p>
</div>
结果
¥Result
规范
Specification |
---|
HTML Standard # attr-itemtype |