This page shows you how to add the structured data that search operators depend on.
Web pages are often filled with free form text, which is easy for humans to read but more difficult for computers to understand. Some web pages have information with greater structure that is easy to read, such as a page date embedded in the URL or title of the page, or machine-readable fields embedded in the HTML code. Google extracts a variety of structured data from web pages. This page describes the structured data types Google extracts that are available for use in Custom Snippets and Structured Search.
- Overview
- Providing Data to Programmable Search Engine
- Providing Data to Rich Snippets
- Viewing Extracted Structured Data
Overview
When you are reading a webpage that sells a DVD, you can quickly figure out what the title is, what reviewers thought of the film, and how they rated it. But a computer cannot do the same things, because it doesn't understand how the information is structured.
For example, if the page has content about the DVD—along with recommendations for other items, ads from other stores, and comments from customers—then the page might have different prices for various things, not just for the DVD that is being sold. You can easily figure out the price for the DVD while dismissing the other prices, but the computer can't. Some sophisticated programs might find the prices in the webpage, but they cannot determine the rules for finding just the price of the DVD.
Structured data formats are rules that standardize the structure and content of the webpage. They are markup that you apply to text snippets so that computers can process their meaning or semantics. The markup does not change the formatting of your website, it just makes the metadata and text enclosed within the XHTML tags more meaningful to computers.
Programmable Search Engine recognizes the following formats:
- PageMaps: invisible blocks of XML that add metadata to pages.
- JSON-LD: invisible structured data using JSON format.
- Microformats: tags used to mark up visible page content along predefined types.
- RDFa: an alternate standard for marking up visible page content along arbitrary types.
- Microdata: a new HTML5 standard for marking up visible page content.
<meta>
tags: standard HTML tags, a subset of which are parsed by Google.- Page Date: features on a page indicating its date, which Google attempts to parse
You can use one or a combination of formats that you prefer. Note that unlike Programmable Search Engine, Google Search uses only JSON-LD, Microdata, and RDFa when generating rich snippets and it has its own algorithm and policies for determining what information gets shown to users. So while an element of structured data you add to your pages may be presented on Programmable Search Engine, that data might not be used in Google Search results.
The following includes an idealized snippet of plain HTML from a review site:
<div> <div> <h1>Pizza My Heart</h1> </div> <span>88%</span> like it <a href="#reviews">See all 12 reviews</a> <span>Under $10 per entree</span> <div>
The following snippet shows the previous HTML code extended with a format called microformats:
<div class="hreview-aggregate"> <div class="vcard item"> <h1 class="fn">Pizza My Heart</h1> </div> <span class="rating average">88%</span> like it <a href="#reviews">See all <span class="count">12</span> reviews</a> <span class="pricerange">Under $10 per entree</span> <div>
By incorporating standard structured data formats into your webpages, you not only make the data available to Programmable Search Engine, but also for any service or tool that supports the same standard. Apply structured data to the most important information in the webpage, so you can present them directly in the results. For example, if you have a website selling Android devices, include structured data about the ratings, prices, availability, and whatnot. When your users search for the Android devices, they can see the ratings, prices, and availability at a glance.
So computers can now understand the types of data in the webpage. Now what? Computers can also start doing the menial task of finding and combining information in different webpages. This frees users from totally boring tasks, such as sifting through multiple pages to find items that they want. Search engines, such as Programmable Search Engine, can process the structured data in your webpages and display it in useful, more meaningful ways, such as custom snippets and structured search.
Providing Data to Programmable Search Engine
Google supports several kinds of data which are used primarily by
Programmable Search Engine: Pagemaps, a subset of <meta>
tags, and approximate page dates.
Using PageMaps
PageMaps is a structured data format that provides Google with information about the data on a page. It enables website creators to embed data and notes in webpages. Although the structured data is not visible to your users or to Google Web Search, Programmable Search Engine recognizes it when indexing your webpages and returns it directly in the Programmable Search Element.
You can explicitly add PageMaps to a page, or submit PageMaps using a Sitemap.
Google will also use other information on a page, such as rich snippets markup or
meta
tag data, to create a PageMap.
Unlike the other structured data formats described below, PageMaps does
not require you to follow standard properties or terms, or even refer
to an existing vocabulary, schema, or template. You can just create
custom attribute values that make sense for your website. Unlike the structured
data attributes of microformats, microdata and RDFa, which are added around
user-visible content in the body of the HTML, PageMaps metadata is included in
the head
section of the HTML page. This method supports arbitrary
data which may be needed by your application but which you might not want to
display to users.
Once you create a PageMap, you can submit it to Google using any of the following methods:
- Add PageMap data directly to your HTML page. Google will discover the PageMap information when we crawl your site.
- Add PageMap data to a Sitemap, and submit that Sitemap for indexing. This is a good option if you don't want PageMap exposed in the HTML source code of your page.
PageMap tag definitions
The following table outlines the requirements for adding PageMap data to a Sitemap.
Tag | Required? | Description |
---|---|---|
PageMap |
Yes | Encloses all PageMap information for the relevant URL. |
DataObject |
Yes | Encloses all information about a single element (for example, an action). |
Attribute |
Yes | Each DataObject contains one or more attributes. |
Note:
PageMaps are XML blocks and therefore must be formatted correctly;
in particular, the PageMap
, DataObject
and
Attribute
tags in the XML are case sensitive, as are the
type
, name
, and value
attributes.
Add PageMap data directly to your HTML page
Here's an example of PageMap data for a webpage about badminton:
<html> <head> ... <!-- <PageMap> <DataObject type="document"> <Attribute name="title">The Biomechanics of a Badminton Smash</Attribute> <Attribute name="author">Avelino T. Lim</Attribute> <Attribute name="description">The smash is the most explosive and aggressive stroke in Badminton. Elite athletes can generate shuttlecock velocities of up to 370 km/h. To perform the stroke, one must understand the biomechanics involved, from the body positioning to the wrist flexion. </Attribute> <Attribute name="page_count">25</Attribute> <Attribute name="rating">4.5</Attribute> <Attribute name="last_update">05/05/2009</Attribute> </DataObject> <DataObject type="thumbnail"> <Attribute name="src" value="http://www.example.com/papers/sic.png" /> <Attribute name="width" value="627" /> <Attribute name="height" value="167" /> </DataObject> </PageMap> --> </head> ... </html>
Add PageMap data to a Sitemap
If you don't want to include PageMap data in the HTML of your pages, you can add PageMap data to a Sitemap and submit that Sitemap via the Search Console Sitemaps tool.
Here's an example of a Sitemap that includes PageMap information for two URLs: http://www.example.com/foo and http://www.example.com/bar.
<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url> <loc>http://www.example.com/foo</loc> <PageMap xmlns="http://www.google.com/schemas/sitemap-pagemap/1.0"> <DataObject type="document" id="hibachi"> <Attribute name="name">Dragon</Attribute> <Attribute name="review">3.5</Attribute> </DataObject> </PageMap> </url> <url> <loc>http://www.example.com/bar</loc> <PageMap xmlns="http://www.google.com/schemas/sitemap-pagemap/1.0"> <DataObject type="document" id="biggreenegg"> <Attribute name="name">Ribs</Attribute> <Attribute name="review">4.0</Attribute> </DataObject> </PageMap> </url> </urlset>
Parsing PageMap data
Using the Programmable Search Element, custom attributes are returned in the richSnippet property of each result, can can be used with Search Element Callbacks.
<r n="1"> <u> http://www.xyz.com/business/vending_machine.html </u> ... <t> In Italy, a Vending Machine Even Makes the <b>Pizza</b> </t> ... <s>The European vending machine industry has annual sales of about #33 billion, much of it coming from factories and offices.</s> ... <PageMap> <DataObject type="image"> <Attribute name="image_src" value="http://www.nytimes.com/images/2009/03/14/business/14vend.751.jpg"/> </DataObject> <DataObject type="publication"> <Attribute name="author" value="John Tagliabue"/> <Attribute name="date" value="March 14, 2009"/> <Attribute name="category" value="Business/World Business"/> </DataObject> </PageMap> ... </r>
Using <meta>
tags
While PageMaps allow you to precisely specify the data you want for
each page, sometimes you have a large amount of content which you do
not want to annotate. Google extracts selected content from
META
tags of the form <meta name="KEY"
content="VALUE">
. We do not support variants of the
META tag, such as the use of property
instead of name
.
While we explicitly exclude common
tags that are usually inserted programmatically by web authoring tools,
such as robots
, description
, and
keywords
, rarer tags specific to your site will be
extracted and put into a special data object
of type metatags
, which can be used with all of Custom
Search's structured data features. For example, a <meta>
tag of the form:
<meta name="pubdate" content="20100101">
creates a PageMap DataObject which is returned in XML results like this:
<r n="1"> ... <PageMap> <DataObject type="metatags"> <Attribute name="pubdate" value="20100101"/> </DataObject> </PageMap> ... </r>
The data in this automatically created PageMap can be used anywhere you can use data from a PageMap explicitly included in your page's content. For instance, it can be used with structured search operators like Sort by Attribute:
https://www.google.com/cse?cx=12345:example&q=oil+spill&sort=metatags-pubdate
or with the Programmable Search Element:
... <div class="gcse-search" sort_by="metatags-pubdate:d:s"></div> ...
- robots
- description
- keywords
- revisit-after
- generator
- verify-v1
- googlebot
- google-site-verification
- mssmarttagspreventparsing
- no-cache
Google attempts to include all other <meta>
tags, with the caveat that
punctuation, special characters and embedded spaces in the name
field of <meta>
tags may not be parsed correctly. Programmable Search Engine
explicitly supports periods and dashes in <meta>
tag names.
Programmable Search Engine does not explicitly support other special characters
within <meta>
tag names, but some special characters
may be accepted correctly if they are
URL encoded.
Limitations
Programmable Search Engine will convert up to 50 <meta>
tags to PageMaps, as long
as the total text size of all processed properties does not exceed 1MB, with no
individual property exceeding 1024 characters.
Using Page Dates
In addition to metadata which you explicitly specify on a page,
Google also estimates a page date based on features of the page such
as dates in the title and URL. Programmable Search Engine allows you to use this
date to sort, bias and range restrict results by using a special metadata
key of date
. This estimated date can be used in all operators
that use the &sort=
URL parameter, including
Sort by Attribute,
Bias by Attribute,
Restrict to Range.
Note: The page date is not added to the PageMap, so it is not returned in JSON API results, cannot be used in the Programmable Search Engine element, and cannot be used with the Filter by Attribute feature.
The following examples show the use of the page date with these operators:
If you want to... | Send this URL... | To learn more see... |
---|---|---|
Sort results by date in descending order | https://www.google.com/cse?cx=12345:example&q=oil+spill&sort=date |
Sort by Attribute |
Bias results strongly towards newer dates | https://www.google.com/cse?cx=12345:example&q=oil+spill&sort=date:d:s |
Bias by Attribute |
Bias results weakly towards older dates | https://www.google.com/cse?cx=12345:example&q=oil+spill&sort=date:a:w |
Bias by Attribute |
Return results from January 1 to February 1 of 2010 (inclusive) | https://www.google.com/cse?cx=12345:example&q=oil+spill&sort=date:r:20100101:20100201 |
Restrict to Range |
Google's estimate of the right date for a page is based on features such as the byline date of news articles or an explicitly specified date in the title of the document. If a page has poorly specified or inconsistent dates Google's estimate of the page date may not make sense, and your Programmable Search Engine may return results ordered in a way you do not expect.
Formatting Dates
A site may provide date information implicitly, relying on Google's estimated page date feature to detect dates embedded in the page URL, title or other features, or explicitly, by supplying a date in a structured data format. In either case, effective use of dates requires formatting the dates correctly.
For Programmable Search Engine's Sort by Attribute, Bias by Attribute, Restrict to Range features, Google attempts to parse dates using both conventional date formatting and formal standards such as ISO 8601 and IETF RFC 850. The following complete date formats are accepted:
Date Format | Example Date |
---|---|
YYYY-MM-DD | 2009-12-31 |
YYYY/MM/DD | 2009/12/31 |
YYYYMMDD | 20091231 |
Month DD YYYY | December 31 2009 |
DD Month YYYY | 31 December 2009 |
Google will attempt to parse variants of these date formats, such
as MM/DD/YYYY
and DD/MM/YYYY
. However,
the more ambiguous the date, the less likely that Google will parse
it correctly. For example, the date 06/07/08
is
extremely ambiguous and it is unlikely Google will assign to it
the interpretation you want. For best results, use a complete
ISO 8601
date format with a fully specified year.
Rich Snippets
Google also extracts a variety of structured data from JSON-LD, Microformats, RDFa
and Microdata to be used in
rich snippets, extended presentations of standard Google search results.
Similar data is available for use in Programmable Search Engine's
structured data operators—typically, the same data used in rich snippets.
For example, if you have marked up your pages with the Microformat
hrecipe
standard, you could sort on the number of rating
stars of the recipe with an operator like
&sort=recipe-ratingstars
.
Google is continually extending the data it extracts and how much of this
data is available for use in Programmable Search Engine; to see what data Google currently
extracts, you can use the
Structured Data Testing Tool in Search Console.
Using JSON-LD
JSON-LD is a widely-used standard format for structured data.
The data is formatted as JSON and placed in a
<script>
tag with type="application/ld+json"
.
The following is minimal bit of HTML with some simple JSON-LD:
<script type="application/ld+json"> { "@id": "http://event.example.com/events/presenting-foo", "@type": "http://schema.org/Event", "http://schema.org/description": "Please attend. You'll love it!", "http://schema.org/name": "Presenting Foo", "http://schema.org/startdate": "2022-05-24", "http://schema.org/location": "Back room" } </script>
Google extracts a subset of this data for Programmable Search Engine and normalizes it. The normalization simplifies the JSON-LD, removing many JSON-LD idioms. The normalized data is processed further:
- It is converted from the graph structure of JSON-LD to a forest of trees.
- The forest is pared down to the branches related to a subset of schema.org types. The subset consists of the schema.org type trees for If you have other types that would be useful for your specific use case, please let us know in the Support Forum.
- Each JSON-LD node from one of the selected types pulls in a branch from its JSON-LD tree. That branch includes its ancestor nodes in the tree and all of its descendant nodes. So, for instance, we may have a tree rooted at a MusicComposition with a firstPerformance property that has an Event value, which has a full set of Event properties. All those nodes, from the MusicComposition through the properties of the Event and any of their descendants are kept to keep a meaningful tree-branch containing the firstPerformance Event.
... "event": { "name": "Presenting Foo", "description": "Please attend. You'll love it!", "startdate": "2022-05-24", "location": "Back room" }, ...
To see what Google Search extracts for a page and validate the JSON-LD, use the Rich Results Testing Tool on Google's Search Console site.
To learn more about JSON-LD, see the structured data documentation and json-ld.org.
Using Microformats
Microformats
is a specification for representing commonly published
items such as reviews, people, products, and businesses. Generally,
microformats consist of <span>
and
<div>
elements and a class property, along with a
brief and descriptive property name (such as dtreviewed
or rating
, which represent the date an item was reviewed
and its rating, respectively).
The following includes a snippet of plain HTML code.
<p><strong>Kevin Grendelzilla</strong></p> <p>Technical writer at Google</p> <p>555 Search Parkway</p> <p>Googlelandia, CA 94043</p>
The following snippet shows the previous HTML code extended with microformats:
<div class="vcard"> <p><strong class="fn">Kevin Grendelzilla</strong></p> <p><span class="title">Technical writer</span> at <span class="org">Google</span></p> <p><span class="adr"> <span class="street-address">555 Search Parkway</span> <span class="locality">Googlelandia</span>, <span class="region">CA</span> <span class="postcode">94043</span> </span></p> </div>
Google extracts a subset of this data, normalized and reorganized to correspond to how it would be displayed in rich snippets. This subset would be returned in XML results like this:
<r n="1"> ... <PageMap> <DataObject type="person"> <Attribute name="location" value="Googlelandia"/> <Attribute name="role" value="Technical Writer"/> </DataObject> </PageMap> ... </r>
To see what Google extracts for a page, use the Structured Data Testing Tool in Google's Search Console site. The data Google extracts from pages is continually being extended, so check back periodically to see if the data you want has been made available. In the meantime, if you need custom data that does not correspond to a defined microformat, you can use PageMaps.
To learn more about microformats, see the structured data documentation and microformats.org.
Using Resource Description Framework in Attributes (RDFa)
Resource Description Framework in attributes (RDFa) is more flexible than microformats. Microformats specify both a syntax for including structured data into HTML documents and set of microformat classes each with its own specific vocabulary of allowed attributes. RDFa, on the other hand, specifies only a syntax and allows you to use existing vocabularies of attributes or create your own. It even lets you combine multiple vocabularies freely. If the existing vocabularies do not meet your needs, you can define your own standards and vocabularies by creating new fields.
The following includes a snippet of plain HTML code.
<div> <h3>5 Centimeters Per Second</h3> <h4>Makoto Shinkai</h4> ... </div>
The following snippet shows the previous HTML code extended with RDFa:
<div> <h3 property="dc:title">5 Centimeters Per Second</h3> <h4 property="dc:maker">Makoto Shinkai</h4> ... </div>
To learn more about RDFa, see the structured data documentation. To learn more about defining an RDF schema, see the RDF Primer.
Using Microdata
HTML5, the latest revision of the language web pages are written in,
defines a format called
microdata
that incorporates the ideas of RDFa and Microformats directly into the
HTML standard itself. Microdata uses simple attributes in HTML tags
(often span
or div
) to assign brief and
descriptive names to items and properties.
Like RDFa and Microformats, Microdata's attributes help you specify that your content describes information of specific types, like reviews, people, information or events. For example, an person can have the properties name, nickname, url, title and affiliation. The following is an example of a short HTML block showing this basic contact information for Bob Smith:
<div> My name is Bob Smith but people call me Smithy. Here is my home page: <a href="http://www.example.com">www.example.com</a> I live in Albuquerque, NM and work as an engineer at ACME Corp. </div>
The following is the same HTML marked up with microdata. Note that in this example we use a property 'nickname' that is not yet officially part of schema.org. Custom Search is a good way to explore possible schema.org extensions locally before proposing them to the wider community.
<div itemscope itemtype="http://schema.org/Person"> My name is <span itemprop="name">Bob Smith</span> but people call me <span itemprop="nickname">Smithy</span>. Here is my home page: <a href="http://www.example.com" itemprop="url">www.example.com</a> I live in Albuquerque, NM and work as an <span itemprop="title">engineer</span> at <span itemprop="affiliation">ACME Corp</span>. </div>
The first line of this example includes a HTML div
tag with
an itemscope
attribute that indicates that div
contains a microdata item. The
itemtype="http://schema.org/Person"
attribute on
the same tag tells us this is a person. Each property of the person item
is identified with the itemprop
attribute; for example,
itemprop="name"
on the span
tag describes
the person's name. Note that you are not limited to span
and div
; the itemprop="url"
tag is attached
to an a
(anchor) tag.
To learn more about microdata, see the structured data documentation and the HTML Microdata standard.
Viewing Extracted Structured Data
JSON-LD structured data has a special Google-supported validation tool, the Rich Results Testing Tool. It checks the syntax of the JSON-LD and also some of its semantics, especially whether the structured data includes required and recommended attributes. To check other forms of structured data, use the Schema Markup Validator. It validates the structured data's syntax, and shows you its interpreted form.
Programmable Search Engine keeps a subset of the structured data, so use a Programmable Search Engine to inspect Programmable Search Engine's view of the structured data for a page by:
- turning on Structured Data in Search Results in Advanced Search Features
-
Then using that search engine to find a page with the data you want to see, and clicking the
Structured data button in the search result for that page:
If you haven't tagged any of your webpages with structured data but would like to see what extracted structured data might look like, you can enter the URLs of other websites. Popular sites that have review information or a list of contacts are especially likely to have structured data.
Once you have found a page with structured data, you can view that page's source to see the structured data that site has implemented. For example, consider the following snippet of HTML with structured data about a person implemented as microformats:
<div class="vcard"> <h1 class="fn"> <span class="given-name">Godzilla</span> <span class="family-name">Gigantis</span> </h1> <span class="title">Senior Giant Monster</span>, <span class="adr"> <span class="locality">Tokyo</span> </span> <div>
Programmable Search Engine extracts the following subset of that data for use in structured search:
person (source = MICROFORMAT) location = Tokyo
Exploring Other Features
Structured data can be used in several Programmable Search Engine features including the following:
- If you want to learn more about using structured data in snippets, see Customizing Your Result Snippets.
- If you want to learn more about changing the order of your results, see Structured Search.