Running dev due to this issue -

I've set up a page title pattern for a content type like so: [node:title] | Consultants | [site:name]

It's a management consultancy website and I want the consultants pages to have a page tile with; Consultants name | Consultants | Site name

The page title pattern is set globally and when I edit the node I see the aforementioned pattern, but the resulting page title on save is just [node:title] | [site:name].

Am i missing something?

#23 1732538-23-page-title-pattern.patch1.07 KBlathan
PASSED: [[SimpleTest]]: [MySQL] 15 pass(es). View
#21 1732538-21-page-title-pattern.patch760 byteslathan
PASSED: [[SimpleTest]]: [MySQL] 15 pass(es). View
#20 1732538-20-page-title-pattern.patch1.11 KBlathan
PASSED: [[SimpleTest]]: [MySQL] 15 pass(es). View
#12 metatag-n1732538-12.patch495 bytesDamienMcKenna
PASSED: [[SimpleTest]]: [MySQL] 15 pass(es). View
#2 Screen Shot 2012-08-15 at 16.28.44.png58.21 KBhixster
#2 Screen Shot 2012-08-15 at 16.28.24.png120.46 KBhixster


Dave Reid’s picture

Status: Active » Postponed (maintainer needs more info)

You need to change the default page title for your node meta tag configuration, not the global configuration.

hixster’s picture

Hi Dave,

Er, just checking, think I was actually referring to the master metatags settings page when using the word 'global' there.

Whilst debugging I changed my settings on the node itself, but also in admin/config/search/metatags
I thought I would need to set the rule 'globally' in admin/config/search/metatags, as this is where the content types get their configuration settings form.
Then i assumed, this could be overridden on a per node basis by setting the page title on the node itself.

I've added some attachments to confirm my settings.

sovarn’s picture

I can confirm the same problem - running on alpha8.

Even though the settings page shows there is an override for my node type. I even go into the node edit form, the metatags tab shows correctly what the title should be.

Clearing cache and resaving doesn't make a difference - the page title is still the global setting.

hixster’s picture

Hi Dave, any thoughts on this?

hixster’s picture

Status: Postponed (maintainer needs more info) » Active

changing to active

DamienMcKenna’s picture

Assigned: Unassigned » DamienMcKenna

Will try to fix this for the next release.

DamienMcKenna’s picture

Incidentally, are other meta tag changes on that node showing up, or is it just the title? What are you using to display the node - normal templates, Panels, Display Suite, etc?

sovarn’s picture

I am just using the normal template.

It does seem to only be a problem with the page titles. The keyword, description, copyright etc meta tags work fine when I override defaults in the node edit form.

Oddly, I just noticed my 'blog post' content type works correctly, whilst all my other content types do not.

I will do more exploring to see why that is.

Salih’s picture

I have similar/same issue with my site

when I was running with Drupal6 all my SEO modules working properly and page-title was showing well. After upgrade to Drupal7 all content page-title shows only default value. But in Page-title configuration I left blank for all content type and checked 'show field' so I can give my own page-title. In node edit form I can see the values once I gave in Drupal6, but unfortunately it doesn't show that value instead it generates default Global value.

for example please check this page:

hixster’s picture

It's just the page title for us. Other tags seem to be working. We're using fusion theme, no custom template mods, display suite etc.

jkempff’s picture

I am having the same issue with alpha8 on a mothership subtheme.

Interesting is that the $page variable in my page.tpl.php contains the overridden - correct - title attribute ($page['content']['metatags']...).

DamienMcKenna’s picture

Status: Active » Needs review
495 bytes
PASSED: [[SimpleTest]]: [MySQL] 15 pass(es). View

Could someone else please test this for me? I believe it resolves the problem by basically only accepting the first value for each $hook:$variable combination, but I want to be sure this is the right way of handling it. The oddity is that on a normal page load (no use of Panels) the head_title variable is being set three times - the first time with the per-object values, the second with the global default values, and the third again with the per-object values - this doesn't make sense to me and I will need to dig further to find out why.

Dave Reid’s picture

The order in which the meta tags are added to the page array are *very important* since it determines which things run "last" and hence are the output values.

DamienMcKenna’s picture

Ok, then there's something strange going on. Try adding this to the top of metatag_set_preprocess_variable:

  if ($hook == 'html') {

First off, it should show an even number of outputs, one for the head_title and one for the head_array, but the first head_title doesn't show.

Secondly, the *first* values that show on the page are the correct per-object versions, the second values are the incorrect global values. When using the built-in taxonomy term page display a third set of head_title/head_array values are output which show the correct per-object versions, but this doesn't happen when using the Panels taxonomy_term page display (with the patch from #1760584).

Suggestions on the direction to take? Am I right in thinking that changing to use hook_entity_view changed means that the correct values load first and that subsequent loads should be discarded?

DamienMcKenna’s picture

Status: Needs review » Needs work

Ok, my solution doesn't work, it doesn't pull in the per-entity override of the global title value, instead it just loads the defaults - the key problem is a deeper architectural problem. Note, this does not affect other meta tags, which work correctly, only the page title is affected.

DamienMcKenna’s picture

This works, but seems wrong:

 * Implements hook_ctools_render_alter().
function metatag_ctools_render_alter(&$info, $page, $context) {
  if ($page) {
    $tags = array_pop(metatag_page_get_metatags());
    foreach ($tags as $name => $tag) {
      if (isset($tag['#attached']['metatag_set_preprocess_variable'])) {
        foreach ($tag['#attached']['metatag_set_preprocess_variable'] as $key => $val) {
          if ($val[0] == 'html' && $val[1] == 'head_title') {
DamienMcKenna’s picture

A suggestion from another issue: change the weight of the global tags to -1.

hixster’s picture

Where should this setting of -1 be applied?

drupalstrap’s picture

same problem here. where do i change the weight? cheers Kevin

lathan’s picture

1.11 KB
PASSED: [[SimpleTest]]: [MySQL] 15 pass(es). View

putting the solution in #16 into a patch that we can use this for now as that seems to work for us right now.

lathan’s picture

760 bytes
PASSED: [[SimpleTest]]: [MySQL] 15 pass(es). View

just removing debug i had left in

marcelovani’s picture

Status: Postponed » Needs work

I found that 'global' was overriding metatags saved on nodes.

I fixed it by editing the following function and moving this line:
$page['content'] = array('metatags' => array()) + $page['content'];
to the bottom as you can see below:

function metatag_page_build(&$page) {
  // For some reason with Overlay enabled we get an empty $page, so just fail
  // this case.
  if (!isset($page['content'])) {
  // Load the metatags render array in before any page content so that more
  // more specific meta tags in the page content can override these meta tags.
  // $page['content'] = array('metatags' => array()) + $page['content'];
  if (drupal_is_front_page()) {
    $page['content']['metatags']['global:frontpage'] = metatag_metatags_view('global:frontpage', array());
  elseif (!path_is_admin(current_path())) {
    // Do not output the global metatags when on an administration path.
    $page['content']['metatags']['global'] = metatag_metatags_view('global', array());
  // Allow more specific items to override global
  $page['content']['metatags'] = array_merge((isset($page['content']['metatags']))?$page['content']['metatags']:array(), metatag_page_get_metatags());

Let me know if that fixes it for you.

lathan’s picture

Status: Needs work » Needs review
1.07 KB
PASSED: [[SimpleTest]]: [MySQL] 15 pass(es). View

@marcelovani idea works better than the patch i had here is a patch file of the change, tested and works for me.

jmart’s picture

#23, please see my comment on another thread. I think the problem is with the ! operator. Not the placement of t

$page['content'] = array('metatags' => array()) + $page['content'];

Also adding

$page['content'] = array();

may be heavy handed because there could be other stuff in that array and you are in effect removing the other elements, no?

marcelovani’s picture

There are many issued regarding the same problem.
Thanks for the patch, but after some tests I noticed that the front page array still gets overridden, so the best idea is to use array_merge
Check this patch for dev version

DamienMcKenna’s picture

Status: Needs review » Postponed

Waiting to see if the problem is resolved by #1784896: Overriding meta tags fall back to parent default tag value.

saitanay’s picture

This may be an issue of your theme as well

I had the same issue where the title tag alone was being ignored.

I found that the custom theme that I was using was in doing the below in themename__preprocess_html(&$vars) function in template.php

$vars['head_title'] = drupal_get_title();

Removing the mentioned line solved the issue.!

lathan’s picture

@DamienMcKenna applied metatag-n1784896-13.patch and metatag-n1700160-29.patch those did not resolve this issue for us.
@saitanay our theme does not contain any setting of head_title in template.tpl.php

marcelovani’s picture

@jucallme can you try this patch
Here is the direct link
Let me know if that fixes it

lathan’s picture

@marcelovani that patch is also not working for us.

marcelovani’s picture

Status: Needs work » Postponed

@jucallme that's weird, on you said it worked for you and doesn't.
The patch I sent to you fixed all our problems with overriding global node and term titles.
I am wondering if you got any module that does drupal_set_title after metatag.

lathan’s picture

@marcelovani i had applied metatag-n1700160-29.patch and your patch that did not resolve the issue the global pattern is not getting overridden for us.

We are running (thats not talked about here) i think that also messes with the page title.

marcelovani’s picture

@jucallme its possible, any module that runs after metatag can override the title. Try to disable the modules, one by one, clearing the cache, to see if you can find the culprit.

You could set the weight of metatag to 10000 to make it load after all other modules.

Have you tried to use metatag (with and without patching) on a new drupal installation to see how it behaves?

DamienMcKenna’s picture

Status: Postponed » Postponed (maintainer needs more info)

@jucallme: Does your theme use a base theme? Have you overridden the html or page template files for your site? What are you using to generate the page output - normal templates, Views, Panels, etc?

DamienMcKenna’s picture

@jucallme: Because you are using Panelizer you will need to patch CTools as well, please see the Panels support issue for further details.

lathan’s picture

@DamienMcKenna thanks

so this recipe seems works for us

- metatag-n1784896-13.patch
- metatag-n1700160-29.patch

- ctools-n1760578-5-d7.patch
- ctools-n1760384-13-d7.patch
- ctools-n1760584-3-d7.patch

navinkmrsingh’s picture

I applied the metatag patches (mentioned in #36) but not the ctools patches as I my Page Manager is uninstalled.
But the problem still persists.
Any Idea??

DamienMcKenna’s picture

navinkmrsingh: What pages are not showing the title correctly - homepage, nodes, terms, users, etc? What is being used for the page display?

DamienMcKenna’s picture

@jucallme: Please try the newest patch on #1760578: Update to execute all normal Drupal hooks, it fixes a typo I let slip in. Also, please post comments on those issues if you've verified each page/entity type works correctly with the patches. Thank you.

DamienMcKenna’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

Marking this as a duplicate of #1784896: Overriding meta tags fall back to parent default tag value though I suspect some of the other issues currently fixed may be part of the problem too.

chrisnovak’s picture

I had the same issue as saitanay, my theme was overriding the head title. Removing the following line from mytheme_preprocess_html() fixed the issue of no head titles displaying correctly:

$vars['head_title'] = variable_get('site_slogan', 'We <3 APIs') . ' ' . (isset($page_title)? $page_title : '') . ' | Apigee Developer Portal';