Addind a meta noindex tag within template.php I would like to add a meta tag noindex from within the template.php file of my theme.

The purpose is to remove two nodes 404 error page from google's index, I would like to do it like so :  

// in mytheme/template.php
function my_theme_preprocess_node(&amp;$variables, $hook) {
   $node = $variables['node'] ;
   // '123' would be nid of the 404 presentation page
   if($node-&gt;nid == '123'){
   /* META NO INDEX CODE GOES HERE */


Is this possible to do in my theme, without using any module at all ?
You could use the following code.

function mytheme_preprocess_node(&amp;$variables, $hook) {
  $node = $variables['node'] ;
  if ($node-&gt;nid == '123') {
    $element = array(
      '#tag' =&gt; 'meta', 
      '#attributes' =&gt; array(
        'name' =&gt; 'robots', 
        'content' =&gt; 'noindex',
      ),
    );
    drupal_add_html_head($element, 'mytheme_noindex');
  }
}


In Drupal 6, you just use drupal_set_html_head('&lt;meta name="robots" content="noindex" /&gt;'), instead of drupal_add_html_head().

I would rather use the code in a module, as a theme should not know details such as the existence of a node with a specific ID. Plus, if the site has more than one theme enabled, or it is possible that a different theme is enabled in future, the code should be copied in each enabled themes, while a module will always be executed, independently from the theme being used.