How do you order meta tags added by drupal_add_html_head()? I'm adding Open Graph support to a Drupal site and I have a bunch of drupal_add_html_head() calls, like:

  $og_title = array(
    '#tag' =&gt; 'meta',
    '#attributes' =&gt; array(
      'property' =&gt; 'og:title', 
      'content' =&gt; $node-&gt;title,
    ),
  );
  drupal_add_html_head($og_title, 'zujava_og_title');

 $og_url = array(
    '#tag' =&gt; 'meta',
    '#attributes' =&gt; array(
      'property' =&gt; 'og:url', 
      'content' =&gt; url('node/' . $node-&gt;nid, array('absolute' =&gt; TRUE)),
    ),
  );
  drupal_add_html_head($og_url, 'zujava_og_url');


In total, I have 10 of these. They don't seem to output in the same order they are called (all in a single function).

Is there some kind of weighting I can use to set the order?
Use the #weight property. As drupal_get_html_head() uses drupal_render() to render the meta tags, #weight is used when rendering them.

I uses the following code to make a test on my local site; it is the same code you are using, except it doesn't have any reference to the node object.

  $og_title = array(
    '#tag' =&gt; 'meta',
    '#attributes' =&gt; array(
      'property' =&gt; 'og:title', 
      'content' =&gt; "This is the title",
    ),
  );
  drupal_add_html_head($og_title, 'zujava_og_title');

 $og_url = array(
    '#tag' =&gt; 'meta',
    '#attributes' =&gt; array(
      'property' =&gt; 'og:url', 
      'content' =&gt; url('node/1', array('absolute' =&gt; TRUE)),
    ),
  );
  drupal_add_html_head($og_url, 'zujava_og_url');

  dsm(drupal_get_html_head());


The output I got is the following one.

&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;meta property="og:url" content="http://tero.local/dr72/node/1" /&gt;
&lt;meta name="Generator" content="Drupal 7 (http://drupal.org)" /&gt;
&lt;meta property="og:title" content="This is the title" /&gt;


As you see, the last added tag is the first to appear.

I then run the following code.

  $og_title = array(
    '#tag' =&gt; 'meta',
    '#attributes' =&gt; array(
      'property' =&gt; 'og:title', 
      'content' =&gt; "This is the title",
    ),
    '#weight' =&gt; 10,
  );
  drupal_add_html_head($og_title, 'zujava_og_title');

 $og_url = array(
    '#tag' =&gt; 'meta',
    '#attributes' =&gt; array(
      'property' =&gt; 'og:url', 
      'content' =&gt; url('node/1', array('absolute' =&gt; TRUE)),
    ),
    '#weight' =&gt; 200,
  );
  drupal_add_html_head($og_url, 'zujava_og_url');

  dsm(drupal_get_html_head());


The output I got is the following one.

&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;meta name="Generator" content="Drupal 7 (http://drupal.org)" /&gt;
&lt;meta property="og:title" content="This is the title" /&gt;
&lt;meta property="og:url" content="http://tero.local/dr72/node/1" /&gt;


As you see, the order of the meta tags has been changed; the meta tags added from the code appear after the default meta tags added from Drupal.

_drupal_default_html_head() (the function that returns the default meta tags) uses #weight for the "Content-Type" meta tag.

  $elements['system_meta_content_type'] = array(
    '#type' =&gt; 'html_tag', 
    '#tag' =&gt; 'meta', 
    '#attributes' =&gt; array(
      'http-equiv' =&gt; 'Content-Type', 
      'content' =&gt; 'text/html; charset=utf-8',
    ),
    // Security: This always has to be output first. 
    '#weight' =&gt; -1000,
  );