drupal, cck content fields and the nodewords module for meta tags and SEO

Submitted by jpamental on

I was a bit annoyed with Drupal when I started working with it about a year ago. Much of the annoyance stemmed from my own inexperience with the platform, but a lingering issue is regarding META tags and Drupal's lack of native support for creating them dynamically. Eventually I found the 'nodewords' module, which does a nice job.

Nodewords adds meta tag description and keyword fields to the node 'edit' view so you can set them explicitly for any given node. For the most part though you can go with the default, which is to allow the module to create a description tag right from the teaser text for the page. This is great, but it does have a flaw. If you've worked with CCK fields and seen what gets generated when you use the default rendered view of $content you'll know what I mean: it's generally an annoying conglomeration of all the defined fields and their labels, along with a bunch of &nbsp;'s and <br>'s. That's what ends up getting pulled into the automatically-generated META description tag. Enter the 'contemplate' module.

Contemplate enables you to create templates for content for teaser, full-node and RSS views without creating a disk-based template file (like 'node-press_release.tpl.php' for a content type of 'press_release'). While I'm generally more in favor of the disk-based method, we discovered that it's perfect for customizing what gets pulled into the teaser, and is then used by the nodewords module to create the META tag. Simply create a template for a given content type, check the box to 'affect teaser' and place a variable in there corresponding to the CCK field containing the main text of the page (or whatever it is you want to use as the source for the META tag.) There is even a nice collapsed text area with all the available variables so it's not too painful a process to figure out the syntax for the right variable.

Once we had that sorted out, it's become quite a handy solution for optimizing pages within a content-managed site in a fairly automatic fashion. I hope this helps - and please let me know what experiences you've had with regard to Drupal and accessibility and SEO. We've had pretty good luck but there's always more to learn from what others have done.