简体   繁体   English

如何正确使用微数据字段?

[英]How do I use Microdata fields correctly?

The process of generating a list of events in a page a bit confusing to me. 在页面中生成事件列表的过程有点令我困惑。

In this example is the url supposed to represent the current page or a page you are referring to? 在这个例子中,url应该代表当前页面或你指的页面?

 <div itemscope itemtype="http://data-vocabulary.org/Person">

Would that be different from this example where I assume it literally does refer to the href? 这会不同于这个例子,我假设它确实引用了href?

 <a href="http://www.example.com" itemprop="url">www.example.com</a>

Can itemprop="locality" be used on zip codes or other postal codes? 邮政编码或其他邮政编码可以使用itemprop="locality"吗?

Also, is there a way to specify you are referring to an Event and not a Person? 另外,有没有办法指明你指的是一个事件而不是一个人?

You definitely seem to have the right idea so far. 到目前为止你似乎肯定有正确的想法。 I have used Schema.org before, for setting up Microdata, and they supply an event property to hook into. 我之前使用过Schema.org ,用于设置Microdata,它们提供了一个事件属性来挂钩。

<div itemscope itemtype="http://www.schema.org/Event">

Also, navigate to the Event information page to get a full readout of what properties it has. 此外,导航到“ 事件信息”页面以获取其所具有的属性的完整读数。

It does have the option for a location with itemprop="location" . 它确实具有itemprop="location"的位置选项。 You can see which Itemscopes you can use location on here . 您可以在此处查看可以使用location Itemscope。 One of the options is PostalAddress which has a some of examples which include using postalCode as a property. 其中一个选项是PostalAddress ,它有一些例子,包括使用postalCode作为属性。

<div itemscope itemtype="http://schema.org/PostalAddress">
 <span itemprop="name">Google Inc.</span>
 P.O. Box<span itemprop="postOfficeBoxNumber">1234</span>
 <span itemprop="addressLocality">Mountain View</span>,
 <span itemprop="addressRegion">CA</span>
 <span itemprop="postalCode">94043</span>
 <span itemprop="addressCountry">United States</span>
</div>

There is also a full tree-view of all of the properties available to hook into. 还有一个可以挂钩的所有属性的完整树视图

The value 'locality' refers to the city of a delivery address, so if you want to specify the postal code you can use the attribute postal-code: 值'locality'指的是送货地址的城市,因此如果您想指定邮政编码,您可以使用邮政编码属性:

<span itemprop="postal-code">99999</span>

Source: http://www.whatwg.org/specs/web-apps/current-work/multipage/microdata.html#names:-the-itemprop-attribute 资料来源: http//www.whatwg.org/specs/web-apps/current-work/multipage/microdata.html#names : -the-itemprop-attribute

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM