0

My custom page.tpl.php is not outputting metatags. I've tried all of these:

 render($page['content'])
 print render($page['content'])
 render($page['content']['metatags'])
 print render($page['content']['metatags'])

I know that the metatags module is passing in the metatag info, because doing this

watchdog('foo', print_r($page['content']['metatags'], true));

results in an array like this:

 Array (
  [node:feed] => Array (
    [abstract] => Array (
      [#attached] => Array (
        [drupal_add_html_head] => Array (
          [0] => Array (
            [0] => Array (
             [#theme] => metatag
             [#tag] => meta
             [#id] => metatag_abstract
             [#name] => abstract
             [#value] => This is an abstract
            )
            [1] => metatag_abstract
          )
        )
      )
    )
    [keywords] => Array (
    [#attached] => Array (
    [drupal_add_html_head] => Array (
    [0] => Array (
      [0] => Array (
        [#theme] => metatag
        [#tag] => meta
        [#id] => metatag_keywords
        [#name] => keywords
        [#value] => keyword1 keyword2
      )
      [1] => metatag_keywords
    )
  )
 )

 ... etc ...

What might be stopping it from rendering the metatags on the page?

I've also noticed that the metatags element in the default devel tab is an empty array, BUT in the tokens tab within devel, the node:metatag tokens are all present and correct.

Further investigation shows that drupal_add_html_head() is being called and the metatag information is being passed in.

3

Turned out someone had overridden html.tpl.php and had removed the reference to $head. Adding echo $head between <head> and </head> in html.tpl.php fixed the problem.

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.