I want to implement support for Google Rich Snippets to show author info and fivestar ratings in Google's search engine results pages. I also want to be able to support Facebook's Open Graph to have Facebook pick the correct image when a node with an image is "liked" or embedded on Facebook.

Looks like I can use Schema.org, microdata or RDFx modules. I also came across a post suggesting to just use a preprocess hook.

The schema.org module doesn't seem to support fivestar ratings. Microdata is relatively new and I'm a bit confused about the RDFX module.

Does anyone have experience with this?

2 Answers 2


In the answer above, there are modules indicated. However, in my experience, they won't work with fivestar, for they are only generic. So, what I usually do in such cases, is to:

  1. Create a template for that node type, like node--type.tpl.php
  2. Create a preprocess function in your theme's template.php file, implementing hook_preprocess_HOOK(). This will translate to an actual function name like mytheme_preprocess_node(&Svariables).
  3. In that function, use the $variables['node'] to get the data from the fivestar widget field.
  4. Format and prepare that data for output, and add your custom variables to the $variables array.
  5. Use the variables you provided in your preprocess function to insert the correct markup in your node file to correspond to the opengraph / rich snippets format.

Some notes:

  1. Use devel module and dpm() function to dump the $variables in preprocess function and the data in the template file.

  2. Use the google markup tool and the facebook markup tool to test your markup.

  3. The logic is, prepare variables in preprocess, and put them in markup in template file. Try not to have computations (business logic) in the template file itself, use preprocess for it.


http://drupal.org/project/opengraph_meta -> it will take the image associated with node or you can specify a default

http://drupal.org/project/richsnippets ->Google Rich Snippets

Not the answer you're looking for? Browse other questions tagged or ask your own question.