I can't imagine that this hasn't been asked before but I couldn't find anything searching the forums or mentioned in any modules so if someone can point me to where I can rtfm to find the information it would be much appreciated.

I'm registering my drupal powered site with icerocket.com and I'm suppose to add some javascript in the HEAD portion of the html body. How does one do that (add content to the head portion of the html) in drupal? I figure that I can manually find the code that generates the content in the head element and insert the code that way, but I figured that this has to be a fairly common customization and that there probably is another way to do it (e.g. via a module?). I searched the modules, but only found the service link module which does not claim to do what I what. I want to add content to the head element of the drupal generated html.

Thanks for any help, references, smacks to the back of the head, etc.

Mindstorm

Comments

cog.rusty’s picture

The <head> section is at the top of your theme's page.tpl.php file.

brenda003’s picture

You'll want to use drupal_add_js, which can be placed either in your template.php file (in your theme directory, create it if it doesn't exist) or within a module.

For example, at the top of your template.php file you could add something like this:

$path = path_to_theme();
drupal_add_js($path .'/custom.js');