微观数据

微数据是 WHATWG HTML 标准的一部分,用于将元数据嵌套在网页上的现有内容中。搜索引擎和网络爬虫可以从网页中提取和处理微数据,并使用它为用户提供更丰富的浏览体验。搜索引擎从直接访问这些结构化数据中受益匪浅,因为它允许搜索引擎理解网页上的信息并向用户提供更相关的结果。微数据使用支持词汇来描述项目,并使用名称-值对来为其属性分配值。微数据试图提供一种比使用 RDFa 和经典微格式的类似方法更简单的方法,用机器可读的标签来注释 HTML 元素。

¥Microdata is part of the WHATWG HTML Standard and is used to nest metadata within existing content on web pages. Search engines and web crawlers can extract and process microdata from a web page and use it to provide a richer browsing experience for users. Search engines benefit greatly from direct access to this structured data because it allows search engines to understand the information on web pages and provide more relevant results to users. Microdata uses a supporting vocabulary to describe an item and name-value pairs to assign values to its properties. Microdata is an attempt to provide a simpler way of annotating HTML elements with machine-readable tags than the similar approaches of using RDFa and classic microformats.

在较高层次上,微数据由一组名称-值对组成。这些组称为项目,每个名称/值对都是一个属性。项目和属性由常规元素表示。

¥At a high level, microdata consists of a group of name-value pairs. The groups are called items, and each name-value pair is a property. Items and properties are represented by regular elements.

  • 要创建项目,请使用 itemscope 属性。
  • 要向项目添加属性,请在该项目的后代之一上使用 itemprop 属性。

词汇

¥Vocabularies

Google 和其他主要搜索引擎支持结构化数据的 Schema.org 词汇表。该词汇表定义了一组标准的类型名称和属性名称,例如,Schema.org 音乐活动 表示音乐会表演,startDatelocation 属性指定音乐会的关键细节。在这种情况下,Schema.org 音乐活动 将是 itemtypestartDate 使用的 URL,位置将是 Schema.org 音乐活动 定义的 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, Schema.org Music Event indicates a concert performance, with startDate and location properties to specify the concert's key details. In this case, Schema.org Music Event would be the URL used by itemtype and startDate and location would be itemprop's that Schema.org Music Event defines.

注意:有关 itemtype 属性的更多信息,请参阅 https://schema.org/Thing

¥Note: More about itemtype attributes can be found at https://schema.org/Thing.

微数据词汇提供 Item 的语义或含义。Web 开发者可以设计自定义词汇表或使用网络上可用的词汇表,例如广泛使用的 schema.org 词汇表。Schema.org 提供了常用标记词汇表的集合。

¥Microdata vocabularies provide the semantics or meaning of an Item. Web developers can design a custom vocabulary or use vocabularies available on the web, such as the widely used schema.org vocabulary. A collection of commonly used markup vocabularies are provided by Schema.org.

常用词汇:

¥Commonly used vocabularies:

主要搜索引擎运营商,如 Google、Microsoft 和 Yahoo!依靠 schema.org 词汇来改善搜索结果。对于某些目的,临时词汇表就足够了。对于其他人,需要设计词汇表。在可能的情况下,鼓励作者重复使用现有词汇,因为这使得内容的重复使用更加容易。

¥Major search engine operators like Google, Microsoft, and Yahoo! rely on the schema.org vocabulary to improve search results. For some purposes, an ad hoc vocabulary is adequate. For others, a vocabulary will need to be designed. Where possible, authors are encouraged to re-use existing vocabularies, as this makes content re-use easier.

本土化

¥Localization

在某些情况下,覆盖特定区域的搜索引擎可能会提供本地特定的微数据扩展。例如,俄罗斯主要搜索引擎 扬德克斯 支持 hCard(公司联系信息)、hRecipe(食品配方)、hReview(市场评论)和 hProduct(产品数据)等微格式,并提供自己的格式来定义 术语和百科全书式文章。此扩展是为了解决西里尔字母和拉丁字母之间的音译问题。由于实现了 Schema 词汇的附加标记参数,俄语网页中的信息索引变得更加成功。

¥In some cases, search engines covering specific regions may provide locally-specific extensions of microdata. For example, Yandex, a major search engine in Russia, supports microformats such as hCard (company contact information), hRecipe (food recipe), hReview (market reviews) and hProduct (product data) and provides its own format for the definition of the terms and encyclopedic articles. This extension was made to solve transliteration problems between the Cyrillic and Latin alphabets. Due to the implementation of additional marking parameters of Schema's vocabulary, the indexation of information in Russian-language web-pages became considerably more successful.

全局属性

¥Global attributes

itemid - 项目的唯一全局标识符。

¥itemid – The unique, global identifier of an item.

itemprop - 用于向项目添加属性。每个 HTML 元素都可以指定一个 itemprop 属性,其中 itemprop 由名称和值对组成。

¥itemprop – Used to add properties to an item. Every HTML element may have an itemprop attribute specified, where an itemprop consists of a name and value pair.

itemref - 不是具有 itemscope 属性的元素后代的属性可以使用 itemref 与该项目关联。itemref 提供了元素 ID 列表(不是 itemid)以及文档中其他位置的附加属性。

¥itemref – Properties that are not descendants of an element with the itemscope attribute can be associated with the item using an itemref. itemref provides a list of element ids (not itemids) with additional properties elsewhere in the document.

itemscope - itemscope 属性(通常)与 itemtype 一起使用来指定块中包含的 HTML 与特定项目有关。itemscope 属性创建 Item 并定义与其关联的 itemtype 的范围。itemtype 属性是描述项目及其属性上下文的词汇表(例如 schema.org)的有效 URL。

¥itemscope – The itemscope attribute (usually) works along with itemtype to specify that the HTML contained in a block is about a particular item. The itemscope attribute creates the Item and defines the scope of the itemtype associated with it. The itemtype attribute is a valid URL of a vocabulary (such as schema.org) that describes the item and its properties context.

itemtype - 指定将用于定义数据结构中的 itemprop(项目属性)的词汇表的 URL。itemscope 属性用于设置 itemtype 设置的词汇表在数据结构中的活动范围。

¥itemtype – Specifies the URL of the vocabulary that will be used to define itemprop's (item properties) in the data structure. The itemscope attribute is used to set the scope of where in the data structure the vocabulary set by itemtype will be active.

示例

¥Example

HTML

html
<div itemscope itemtype="https://schema.org/SoftwareApplication">
  <span itemprop="name">Angry Birds</span> - REQUIRES
  <span itemprop="operatingSystem">ANDROID</span><br />
  <link
    itemprop="applicationCategory"
    href="https://schema.org/SoftwareApplication" />

  <div
    itemprop="aggregateRating"
    itemscope
    itemtype="https://schema.org/AggregateRating">
    RATING:
    <span itemprop="ratingValue">4.6</span> (
    <span itemprop="ratingCount">8864</span> ratings )
  </div>

  <div itemprop="offers" itemscope itemtype="https://schema.org/Offer">
    Price: $<span itemprop="price">1.00</span>
    <meta itemprop="priceCurrency" content="USD" />
  </div>
</div>

结构化数据

¥Structured data

itemscope itemtype 软件应用([https://schema.org/SoftwareApplication](https://schema.org/SoftwareApplication))
itemprop name 愤怒的小鸟
itemprop operatingSystem ANDROID
itemprop applicationCategory 软件应用([https://schema.org/SoftwareApplication](https://schema.org/SoftwareApplication))
itemscope 项目属性[项目类型] 聚合评级 [聚合评级]
itemprop ratingValue 4.6
itemprop ratingCount 8864
itemscope 项目属性[项目类型] 优惠[优惠]
itemprop price 1.00
itemprop priceCurrency USD

结果

¥Result

注意: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 above.

也可以看看

¥See also