Tag Archives: custom meta

Drupal 6, programtically add custom meta tags to pages

Assuming that we need to add custom meta tags by page url or node type, drupal hook_preprocess_page() is the last function called before displaying the page, so it’s the right place for doing that :

 * Implementation of hook preprocess_page
 * @param array $variables
function my_module_preprocess_page(&$variables) {
    //using path
    if(arg(1) == 'gallery'){
      //load existing node
      $node = node_load(arg(2));
     // the meta content.
      $head = ' .. ';
      $variables['head'] = drupal_get_html_head();

In this case path is : gallery/[nid]