Add Metadata to a Drupal Node

By Jimmy Bonney | August 12, 2011

Cart

While trying to ensure that a website created in Drupal was correctly verified with Google webmasters tools, I needed to add some metadata to the homepage of the website. Since this was a one shot only operation, it was not necessary to modify the full website template. Instead, in such cases, it can be done quite easily by adding the following bit of PHP code to the body of the home page and to ensure that the input format is set to PHP code.

1
2
3
4
<?php
    $meta = '<meta name="google-site-verification" content="ABCDEFGHWy6OxJzyJkzWGq4Um7FXYZTUVW" />';
    drupal_set_html_head($meta);
?>

The function drupal_set_html_head is fully documented in Drupal API. Put simply, it allows to add code in the head tag of the HTML output.


Credits Image

m-files

For the time being, comments are managed by Disqus, a third-party library. I will eventually replace it with another solution, but the timeline is unclear. Considering the amount of data being loaded, if you would like to view comments or post a comment, click on the button below. For more information about why you see this button, take a look at the following article.