Friday, July 1, 2011

Adding meta description & keywords to the Drupal 7 head

You can use drupal_add_html_head() for adding meta description and meta keywords in header. In your theme template.php file, you can call hook_page_alter() for embeding meta. If you want to add meta description and meta keywords in your site then go to your template.php file and paste the code (display below):

function YOURTHEMENAME_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' );
}

7 comments:

pepper said...

that's totally useless

Anonymous said...

yes. totally stupid way.....

Anonymous said...

Your ѕtyle is very unique сomρarеd to
other fοlks Ι have read stuff from. Many thаnkѕ for ρosting whеn you've got the opportunity, Guess I will just book mark this web site.

My web page ... Boston Car Service

Anonymous said...

This is useless. It's not working. It renders my page; BLANK!!!
Best solution; use a module by name.....meta tag.

Anonymous said...

Thanks for sharing your thoughts about purchasing mattress toppers.

Regards

Feel free to visit my blog ... organic wool mattress protector

Anonymous said...

Good way of telling, and good post to obtain data regarding my presentation subject, which i am going
to convey in school.

Also visit my web-site: mold inspection brooklyn ()

Anonymous said...

smokeless cigarettes, e cigarette forum, ecig, ecigarette, e cig forum, electronic cigarette