Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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..

e.g:

/**
 * 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
add comment

Your Answer

 
discard

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.