Adding META tag to nodes with a specific topic If a node has a term reference to a specific term (say termid 123) I want to add this META tag to prevent search engine spiders from indexing the page:

&lt;meta name="robots" content="noindex"&gt;


Is hook_page_build() the right hook for this?
I think you definitely could use hook_page_build() (it would work), but since that hook is really intended for use with page.tpl.php, and meta tags are outputted in html.tpl.php, I think it might not be the 'Drupal' way.

Another option might be to use hook_html_head_alter(), which allows you to alter the &lt;head&gt; tags before they're rendered:

function MYMODULE_html_head_alter(&amp;$head_elements) {
  if ($node = menu_get_object()) {
    $tid = function_to_get_term_id();
    $related_tids = field_get_items('node', $node, 'field_FIELD_NAME');

    if (!empty($related_tids) &amp;&amp; $related_tids[0]['tid'] == $tid) {
      $head_elements['MYMODULE_meta_robots'] = array(
        '#tag' =&gt; 'meta',
        '#type' =&gt; 'html_tag',
        '#attributes' =&gt; array(
          'name' =&gt; 'robots',
          'content' =&gt; 'noindex'
        )
      );
    }
  }
}


You might also want to look at adding rel="nofollow" attributes on the links to those node in teaser displays, it might help speed up the process a bit.