Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am currently looking at the SEO of our site, and I will be using schema.org microdata in the head and 'rich snippets', as well as including facebook opengraph data. What is the best way to include this information in the header, extract it from the content etc. Are there any moduls that can help out with this task? Are there any best practices?

share|improve this question
What version of Drupal? It matters here. – MPD Feb 20 '13 at 18:35
It is version 7. I know that this seo stuff changes so rapidly – Andrew Welch Feb 20 '13 at 20:19
up vote 1 down vote accepted

You can use Drupal hooks and functions like

You could also call drupal_add_html_head from other API hooks such as hook_node_view, hook_ctools_render_alter, hook_init etc..


 * Implements hook_preprocess_html
function mytheme_preprocess_html(&$vars) {

  $content = drupal_get_title() ? drupal_get_title() : variable_get('site_name', 'Drupal');
  // Add open graph title to head
  $element = array(
    '#tag' => 'meta', 
    '#attributes' => array(
      'property' => 'og:title', 
      'content' => strip_tags($content) 

  drupal_add_html_head($element, 'fb_social_open_graph_title');

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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