Sunday, April 01, 2012

How to add meta description and keywords to header in drupal 7

Adding meta description and meta keywords in Drupal 7 is different compared with Drupal 6. I used drupal_add_html_head() for
adding meta description and meta keywords in header. In my theme (template.php file), I call hook_page_alter() for embeding meta. If you want to add meta description and meta keywords in your site then go to your site default theme folder’s template.php file and paste the code (display below) :

function yourtheme_page_alter($page) {
$meta_description = array(
'#type' => 'html_tag',
'#tag' => 'meta',
'#attributes' => array(
'name' => 'description',
'content' => 'some description here'
));
$meta_keywords = array(
'#type' => 'html_tag',
'#tag' => 'meta',
'#attributes' => array(
'name' => 'keywords',
'content' => 'some, keywords'
));
drupal_add_html_head( $meta_description, 'meta_description' );
drupal_add_html_head( $meta_keywords, 'meta_keywords' );
}
Or you can use module Meta Tags Quick
http://drupal.org/project/metatags_quick

0 comments:

Post a Comment