Schema.org - creating a web feed
Schema.org provides a collection of schema's that webmasters can use to markup HTML pages in ways recognized by major search providers, and that can also be used for structured data interoperability (e.g. in JSON). Search engines including Bing, Google, Yahoo! and Yandex rely on this markup to improve the display of search results, making it easier for people to find the right Web pages.
Many sites are generated from structured data, which is often stored in databases. When this data is formatted into HTML, it becomes very difficult to recover the original structured data. Many applications, especially search engines, can benefit greatly from direct access to this structured data. On-page markup enables search engines to understand the information on web pages and provide richer search results in order to make it easier for users to find relevant information on the web. Markup can also enable new tools and applications that make use of the structure.
A shared markup vocabulary makes it easier for webmasters to decide on a markup schema and get the maximum benefit for their efforts. So, in the spirit of sitemaps.org, search engines have come together to provide a shared collection of schemas that webmasters can use.
More info can be found at schema.org.
Here we give you some small examples on how it works and where you can use it.
We use Microdata to nest metadata into existing content on web pages,
you can also use RDFa and JSON-LD.
Example
First we have a example in HTML and later we add the Microdata.<div> <h1>The Hunger Games</h1> <span>Writer: Suzanne Collins (born August 10, 1962)</span> <span>Science fiction</span> <span>Published <i>September 14, 2008</i></span> Pages: <i>374</i> ISBN: <i>978-0-439-02352-8</i> </div>
And now with Microdata:<div itemscope itemtype="http://schema.org/Book"> <h1 itemprop="name">The Hunger Games</h1> <span>Writer: <div itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">Suzanne Collins</span> (born <meta itemprop='birthDate' content="1962-08-10">August 10, 1962)</div></span> <span itemprop="genre">Science fiction</span> <span>Published <i>September 14, 2008</i><meta itemprop='datePublished' content="1962-08-10"></span> Pages: <i itemprop="numberOfPages">374</i> ISBN: <i itemprop="isbn">978-0-439-02352-8</i> </div>
itemscope and itemtype
First you have to tell what it is about, you this with itemscope and itemtype.
I this case it is about a book (so itemtype="http://schema.org/Book").
But you can use several types:
- Creative works: CreativeWork, Book, Movie, MusicRecording, Recipe, TVSeries, ...
- Embedded non-text objects: AudioObject, ImageObject, VideoObject
- Event
- Organization
- Person
- Place, LocalBusiness, Restaurant, ...
- Product, Offer, AggregateOffer
- Review, AggregateRating
itemprop
Of course you have to add the title, here referred to as name<h1 itemprop="name">The Hunger Games</h1>
Basically every aspect of the book starts with itemprop="*".
You can merge it with HTML-code, as we did with the title/name,
But it can also be done with none-visible meta-tags, like we do with the dates.
Nested items
Inside the itemscope book, we added an itemscope person:
<span>Writer: <div itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">Suzanne Collins</span> (born <meta itemprop='birthDate' content="1962-08-10">August 10, 1962)</div></span>
Because the author is a person. Inside this itemscope the itemprop (name, birthdate) are linked to the person and not to the book.
Dates
Although humans can easily read different type of dates, computers and so search-engines have more problems with it.
So we use a standard ISO 8601 date format, in short the following format YYYY-MM-DD,
or if you want to add hours and minutes 2015-02-21T19:30
Because we don't want it to be visible we put it inside a <meta>-tag:
<meta itemprop='datePublished' content="1962-08-10">
You can also add duration, for example cooking receipt,
It always start with the letter P (stands for "period").
<time itemprop="cookTime" datetime="PT1H30M">1 1/2 hrs</time>
Remarks
It is important to remember that the data inside the itemprop-tags, must only be the data.
for example the pages of the book:
Good:Pages: <i itemprop="numberOfPages">374</i>
Bad:Pages: <i itemprop="numberOfPages">374 pages</i>
For more information and for a list of all the possible itemprop's, check the site schema.org.
You can test your code on https://developers.google.com/structured-data/testing-tool/