Drupal Nodewords module and Zen themes

Nodewords is an absolutely essential Drupal module. In fact, I am not sure why its features are not implemented in Drupal out-of-the-box. I was quite shocked to discover that Drupal doesn’t include support for meta tags, so basically there is no way to add keyword and description meta tags to your pages (or “nodes” as they are called in Drupal – why? no idea) unless you install and configure Nodewords.

So you do.

And then… it doesn’t work. Blast! But you went through all the required steps… Let’s check them all again. You installed the module, enabled it, configured the “http://www.yoursite.com/admin/content/nodewords” page, set permissions and created those nice meta tags on your pages… You look at the HTML: no tags! What the…

If only those clever Nodewords guys had remembered to mention that the module doesn’t work in Drupal themes that don’t call the $head variable. Like Zen and Chameleon for example.

Solution? Simple. Give some $head. No, seriously now. Go to your Zen (or whichever) theme’s folder, open page.tpl.php.
Replace the following code:

<head>
<title><?php print $head_title; ?></title>
  <?php print $styles; ?>
  <?php print $scripts; ?>
</head>

with this:

<head>
<?php print $head ?>
<title><?php print $head_title ?></title>
  <?php print $styles; ?>
  <?php print $scripts; ?>
</head>

Hurray! The meta tags will now appear in your HTML output, provided you have configured nodewords properly of course.

Now, I just wish someone had told me this before: I wouldn’t have spent a whole afternoon banging my $head against the $wall