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 modules that can help out with this task? Are there any best practices?


1 Answer 1


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');


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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