Last updated April 5, 2012. Created on June 7, 2011.
Edited by klonos, linclark. Log in to edit this page.

With HTML5's microdata, you can share bits of information between sites. For example, you can share 5-star reviews or song length with Google so that the information can be displayed in Rich Snippets.

Google Rich Snippets

But besides sharing the information with Google, microdata is also used to share information with the rest of the Web. This means that you can build your own distributed networks of sites that share content easily.

How microdata works

Microdata talks about things (items) and their properties. The values of properties can be strings or they can be other items. For example, you could be talking about a person (item) who has the following properties:

  • a name (string)
  • knows another person (item)

Microdata expresses these relationships by adding attributes to HTML tags. These tags can be hard to add by hand, which is where the microdata module comes in.

To get microdata output, follow these steps:

  1. Figure out how you want your content to be used and by whom
    The only reason to use microdata is to share content with others, so you'll want to figure out your target audience. For example, you may want your pages to show up with nice formatting in the major search engines. In that case, the major search engines are your target consumer.
  2. Find out which vocabulary is used by your target consumer
    A vocabulary is necessary for communicating with your target consumer. In the case of the major search engines, this vocabulary is Schema.org.
  3. Compare your site's content types and fields to the vocabulary's itemtypes and properties
    For example, if you have an Event, you would want to look for something similar in the microdata vocabulary. Schema.org has http://schema.org/Event. This has properties which will probably map pretty well to the fields on your content type, such as startDate and endDate.
  4. Check whether the field has microdata integration
    Because microdata is quite particular in where attributes can be placed, most field formatters need to have microdata attributes placed within the formatter code itself. This requires updating modules on Drupal.org. There are issues to track this, and there is a table to keep track of them. If the field is not listed, search for 'microdata' in the module's issue queue. If you don't find an issue, you can add one (and remember to update the table!)
  5. Add the itemtype and properties to your content type's settings
    Once microdata is enabled, you will see form fields on all content types and microdata-enabled fields. Just enter the appropriate itemtype (i.e. http://schema.org/Event) and property names (i.e. startDate). The placement of the HTML will be taken care of by the module.
AttachmentSize
webmasters_99170_rsreview_en.png68.56 KB

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.