1

I have a request to change the order that meta items are printed in the head using the contrib module Nodewords in D6. More specifically the property would like the description to appear before the keywords (per their SEO consultant).

Is this possible? Fruitless? Stupid?

I have searched with no results so far.

2
  • Which version of nodewords are you using ? – tostinni Jun 15 '11 at 0:16
  • Nodewords version 6.x-1.11 -- I can upgrade if necessary – jeff_shamley Jun 15 '11 at 3:57
1

You can implement hook_nodewords_tags_alter which will alter the rendering of the tags. It accepts function MODULENAME_nodewords_tags_alter(&$output_tags, $tag_options) {}.

But why do you want to do this ? Any SEO insight you might share with us ?

2
  • sorry for the delay. according to our SEO consultant, Google recommends meta tags display in the head in this order title>>description>>keywords -- I am not an SEO wizard so this insight is news to me. – jeff_shamley Jun 16 '11 at 20:17
  • 1
    @jeff good to know, maybe this could lead to some improvement of the nodewords module ;) – tostinni Jun 16 '11 at 20:21
1

I'm going to add hook_nodewords_tags_info_alter() to the next release of 1.x: http://drupal.org/node/1730808

Damien McKenna Nodewords maintainer

0

If you are using the branch 6.x-2, you need to implement hook_nodewords_tags_info_alter() to alter the weight index contained in the array returned by the implementations of hook_nodewords_tags_info().

The weight is used by _nodewords_output_tags(), which is the function that renders the HTML output for the meta tags. Once the function has built the array of HTML strings to output, it sorts the array using the following code:

if (count($output)) {
  array_multisort($weights, $output);

  return implode("\n", $output);
}
else {
  return '';
} 

$weights is the array containing the weight of every output meta tag.

I don't see any reason to change the weight of a meta tag, if not in a specific case where a meta tag consumer looks for two meta tags, and uses the first one that finds. Without a specific and valid reason, changing the weight of meta tags is useless, as meta tag consumers don't normally depend from the order meta tags are present in the HTML output.

_nodewords_output_tags() is called after the implementations of hook_nodewords_tags_alter(); altering the order of the array items in hook_nodewords_tags_alter() doesn't then have any effect.

nodewords_load_all_includes('nodewords.hooks.inc');
drupal_alter('nodewords_tags', $output_tags, $options);
$output = _nodewords_output_tags($output_tags);
drupal_alter('nodewords_tags_output', $output, $options);
2
  • What I reported in my answer is probably true for the 6.x-1 branch too; I didn't look at the code, and I cannot report any difference between the branches too. – kiamlaluno Jun 15 '11 at 0:05
  • Nope doesn't exists in the 6.x-1 branch... – tostinni Jun 15 '11 at 0:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.