This page describes how to customize the result snippets for your own website. To render your customized snippets, you must add structured data to your webpages and create a presentation layer to transform the XML feeds of the search results.
Note: XML feeds are available only to Google Site Search customers and Custom Search partners. If you do not have a Site Search account, upgrade your Custom Search account by signing in to your Custom Search control panel, selecting the Business settings tab, and clicking the Convert to Google Site Search button. Any level of service gives you access to the XML feeds.
- Overview
- Creating Rich Snippets with the Custom Search Element
- Creating Custom Snippets from XML Feeds
- Exploring Other Features
Overview
Custom Search helps users find the right page by showing them a snippet—a small sample of content that gives search users an idea of what's in the webpage. To learn more about snippets, see the Webmaster Central blog post on the anatomy of a search result. If you do not like the standard snippets created by the Custom Search algorithm, you can create your own snippets. You can showcase key information—such as image thumbnails, summaries, dates, authorship, ratings, and prices—directly in your snippets. Having the most relevant information in your search results makes the webpages in your site more compelling to your users.
The following figures demonstrate various ways you can customize the snippets in your search results.
Figure 1: Result snippet with rating, price range, and review.
Figure 2: Result snippet with formatting, links, image, and comparative information.
Figure 3: Result snippet that includes document types, authors, page views, and comments.
Figure 4: Richly formatted result snippet that provides multimedia access and buttons ("ADD TO CART").
Creating Rich Snippets with the Custom Search Element
Essentially, creating rich snippets involves the following steps:
- Provide structured data in your webpages.
When Custom Search is indexing your webpages, it recognizes and preserves the metadata.
- Fetch that structured data in the search results for your Custom Search Engine.
The Custom Search server can return the search results, along with the structured data, in XML or JSON format.
- Create a presentation layer to transform the structured data into formatted HTML.
A presentation layer is a set of code (such as JavaScript, PHP, JSP and ASP) that transforms the raw data into a format that is displayed to the user. In the case of Custom Search, you can:
- Use the Custom Search element to transform JSON output for presentation to the user. The Custom Search element provides you with a presentation layer in the form of data templates; the data templates documentation gives details on how to use this rendering method.
- Write your own custom presentation layer that transforms XML data to HTML that is presented to the end user.
Structured data extraction is documented in more detail in the Structured Data page, and creating a presentation layer with the Custom Search element is documented in more detail at the Custom Search element page.
Creating Custom Snippets from XML Feeds
While the Custom Search element is the easiest way to modify the
appearance of your search results, it might not meet your needs.
If you are a Site Search customer or a Custom Search partner, you can
receive your search results as XML and create a custom presentation
of those results using your site's application framework. To retrieve
XML feeds for your search results, send a
GET
request to the following URL:
https://www.google.com/cse?cx=<CSE ID>&q=<query term>&output=xml
Note: This is not available to regular Custom Search accounts. Consult your application framework's documentation on how to parse XML results.
The following is an example of a GET
request that retrieves the results XML for the query, "Einstein."
GET https://www.google.com/cse?cx=999999999999999999999:srraaaaaaaa&q=einstein&output=xml
The Custom Search server responds with the results XML. If the webpage has structured data, the data is included.
<GSP VER="3.2"> <TM>0.405150</TM> <Q>einstein</Q> <PARAM name="cx" value="cx=999999999999999999999:srraaaaaaaa" original_value="cx=999999999999999999999:srraaaaaaaa"/> <PARAM name="q" value="einstein" original_value="einstein"/> <PARAM name="output" value="xml" original_value="xml"/> <PARAM name="adkw" value="AELymgUxINzkwsr2ClnvOZ4bodqf4MPdK634hYkFSIGs9-bHCGP_obrUjCfugy_8JPaHjXINX6NJt_fOotOsBkrtj9OxtZAWHgc2a2jRPl3OfKVbQgAluMA" original_value="AELymgUxINzkwsr2ClnvOZ4bodqf4MPdK634hYkFSIGs9-bHCGP_obrUjCfugy_8JPaHjXINX6NJt_fOotOsBkrtj9OxtZAWHgc2a2jRPl3OfKVbQgAluMA"/> <PARAM name="hl" value="en" original_value="en"/> <PARAM name="oe" value="UTF-8" original_value="UTF-8"/> <PARAM name="ie" value="UTF-8" original_value="UTF-8"/> <PARAM name="client" value="google-csbe" original_value="google-csbe"/> <PARAM name="boostcse" value="0" original_value="0"/> − <Context> <title>Genius Search Engine</title> </Context> − <RES SN="1" EN="10"> <M>569000</M> − <NB> − <NU> /custom?q=einstein&hl=en&client=google-csbe&cx=cx=999999999999999999999:srraaaaaaaa&boostcse=0&output=xml&ie=UTF-8&oe=UTF-8&start=10&sa=N </NU> </NB> <RG START="1" SIZE="10"/> <RG START="1" SIZE="1"/> − <R N="1"> − <U> http://www.scribd.com/doc/48868/Albert-Einstein-The-World-as-I-See-It </U> − <UE> http://www.scribd.com/doc/48868/Albert-Einstein-The-World-as-I-See-It </UE> <T>Albert <b>Einstein</b> - The World as I See It</T> <RK>0</RK> − <S> May 10, 2007 <b>...</b> The collection of thoughts on various scenarios by Albert Einstein Religion <br> <b>Einstein</b> Albert Religion-Christianity Business-Asian. </S> <LANG>en</LANG> <Label>_cse_srraacmywxi</Label> − <PageMap> − <DataObject type="document"> <Attribute name="title">Albert Einstein &ndash The World as I See It</Attribute> <Attribute name="author">pablasarabjot</Attribute> <Attribute name="description"> The collection of thoughts on various scenarios by Albert Einstein </Attribute> ... <Attribute name="thumbnail_url"> http://i5.scribdassets.com/profiles/images/dbw8y5a0etg2a-thumb.jpg </Attribute> <Attribute name="filetype_image"> http://www.scribd.comhttp://s7.scribdassets.com/images/filetypes/pdf_16x16.gif?1256049874 </Attribute> </DataObject> </PageMap> ....
Exploring Other Features
Custom Snippets works well with several other Custom Search features:
- If you want to learn more about changing the order of your results, see Drilling Deeper into Search Results.
- If you want to learn more about what structured data Google supports, see Providing Structured Data.
- If you want to learn more about the Custom Search element, see Custom Search element documentation.