Hello, i have a overwritten template of front, and all works fine with:

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

But in alpha4 dont work for me, it have a NULL value

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

PazZze’s picture

I'm borrowing your issue (though it was stupid to create a new one with the same title)

My meta tags wont show up at the front page. I found all meta tags I've configured on any other page on my homepage.
I've only configured "Global" value, the rest is unconfigured right now. I've tried to configure it in all different way I could think of.

So my hope is to you to find a solution to this =)

/Joel

hles’s picture

I confirm that with the same configuration as PazZze: Global metatags are set, Global Frontpage are set, rest is not set.
For example, on the frontpage, the page title of the Global configuration is displayed when the one of Global Frontpage was expected.
Version alpha4 used.

hles’s picture

Well, I found the problem.
I configured only default metatags: first global and then frontpage. The metatags for the node I use for the frontpage were automatically filled in with wrong default values from Global and frontpage, and not just frontpage like expected.

That being said, I'm not sure why there should be metatags values filled in on this frontpage node because it was using default and the node's metatags were not overridden by me. In that case, I would expect the node metatags fieldset saying "Using default" (which was the case) and have no metatags values in the node's metatags fieldset's fields.

I removed all the metatags from the frontpage node and now all the default metatags are used like they should.

mrmeech’s picture

I can also confirm that meta tags on the front page are not working whatsoever, regardless of what is (or is not) overridden.

EDIT: After finding this thread, i found this other one which has a much bigger discussion seemingly related to this same issue, so for anyone else: http://drupal.org/node/1293214

EDIT 2: As it turns out, you NEED to do render($page['content']) in page--front.tpl.php or the meta tags won't get inserted on the front page. If you don't have a page--front.tpl.php, check your page.tpl.php and make sure it's being output... my problem was i put some custom front page content within a if($is_front){...} block and the render call was within a if(!$is_front){...}, so the render call never happened on if it was the front page.

enrikito’s picture

+1

_gramur’s picture

Is there any kind of work around for those who don't use

<?php
 render($page['content']) 
?>

For example if a front page uses custom regions which relies on Views?

mrmeech’s picture

If you find yourself in a situation where you get the "No front page content..." message (like i did) as a result of absolutely needing render($page['content']); in your front page template to get the metatags on the front page, then you can unset that from output. So, to do that:

     unset($page['content']['system_main']['default_message']);
     print render($page['content']);
swfindlay’s picture

If you're using Drupal 7 add your meta tags into: html.tpl.php (not page.tpl.php). Html.tpl.php is either in your theme folder, or if not its in module/system.

Hope that helps

jisuo’s picture

And exactly what should you print in html.tpl.php?

Shaltay’s picture

Same here.
I m using danblog theme
overwriting html.tpl.php does not work for me.

Danny Englander’s picture

I believe this is similar to or a duplicate of: Front Page Meta Description

davidtrainer’s picture

If you are using zen, you may want to check out #1551340: $page['content'] is missing in hook_page_build.

marcoka’s picture

so basically you remove page variables/use a custom theme and wonder why stuff does not show up? so does it work with the core std theme? if so its an issue of the theme you use.

arpieb’s picture

We're running into the same thing, however our case involves a front-page node that has no renderable content in it (more of a placeholder as we didn't want a sep page--front.tpl.php file), which the metatags module will not render metatags for due to this piece of logic in the metatag_page_build function:

  // For some reason with Overlay enabled we get an empty $page, so just fail
  // this case.
  if (!isset($page['content'])) {
    return;
  }

The attached patch simply creates an empty $page['content'] element instead of returning so normal metatag processing can take place.

DamienMcKenna’s picture

Version: 7.x-1.0-alpha4 » 7.x-1.x-dev
Status: Active » Postponed (maintainer needs more info)

Rather than hacking away trying to get this working, and ultimately building work-arounds for an existing work-around in Metatag, the output logic has been re-written thanks to jenlampton and I'm hoping it works better now. Please try the latest -dev release and please let me know if it works as-is, and re-open the issue if it's still not working.

That said, please be aware that right now it doesn't let you override tags for taxonomy term pages due to a core bug, please keep an eye on #1700160: Support taxonomy term pages until taxonomy supports hook_entity_view() for further updates.

DamienMcKenna’s picture

Related and honestly a higher priority: #1708718: Ensure Meta tags work OOTB with Drupal core

I'm going to fix that and then see how to resolve this issue.

DamienMcKenna’s picture

Status: Postponed (maintainer needs more info) » Fixed

This should have been resolved by #1784896: Overriding meta tags fall back to parent default tag value. If you are still having the problem then it is a theming issue, please get involved with / follow #1800658: Front page settings don't work on some themes (e.g. TopHit).

DamienMcKenna’s picture

Status: Fixed » Closed (fixed)
mustafa.ata’s picture

Title: Metatags in front not working » SOLUTION: Metatags in front not working
Status: Closed (fixed) » Active

SOLUTION:

In my scneario I have Drupal 7, custom theme which has html.tpl.php and page--front.tpl.php and Metatag 7.x-1.0-beta4. I went through all the above comments. I found the solution by adding this code in page--front.tpl.php.

Code is:

render($page['content']); 

What i did was I rendered the content but didnot printed it. I got the impression from previous comments that Metatag module working requires rendering of content. I did it and succeeded.

Posting a comment so that other can take help out of it and can save their time which I spent on it while finding the solution

THanks

Ata ul Mustafa

DamienMcKenna’s picture

@Ata: Does it work if you do render($page['content']['metatags']); ?

willvincent’s picture

render($page['content']['metatags']);
Fixes it for me with beta2

mustafa.ata’s picture

Yes Damien, it also worked for me.

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

Are you getting any issue?

Thanks

Ata

DamienMcKenna’s picture

Component: Code » Documentation
Category: bug » task
DamienMcKenna’s picture

Status: Active » Needs review
FileSize
849 bytes

This adds the following lines to the Known Issues section of the README.txt file:

* When using custom page templates it is important to ensure that the following
  code is in the template file:
    <?php render($page['content']); ?>
  or
    <?php render($page['content']['metatags']); ?>
  Without one of these being present the meta tags will not be displayed.

I've also renamed the Known Issues section to "Troubleshooting / Known Issues" to help draw attention to it.

DamienMcKenna’s picture

Closed another duplicate: #1941638: page--front.tpl.php

DamienMcKenna’s picture

FileSize
889 bytes

A small update that gives an example of a template file's filename.

DamienMcKenna’s picture

Status: Needs review » Fixed

Committed.

DamienMcKenna’s picture

Status: Fixed » Closed (fixed)

Now that Metatag v7.x-1.0-beta5 is out am closing this to keep the issue queue clean.

pkhlop’s picture

* Zen sub theme
* custom template for page--front.tpl.php
* empty $page['content'] or $page['content']['metatags']) on front page

Solution:

put this code at top of page--front.tpl.php

render(metatag_metatags_view('global:frontpage', array()));
dpjef’s picture

Had a problem that metatags on frontpage were not showing what I entered.

On the module's settings page, you can set the metatag pattern specifically for the frontpage and for nodes.

I solved it by manually typing the page title and description metatag for the frontpage here.

airstarh’s picture

#29 helps!
Thank you!.. But why...

fahadurrehman’s picture

I was also not using $content on Front page, in my page.tpl.php. On using that metatags works but was displaying message ""no front page content" so I have installed Empty Front Page Module and it removes that message.

manoloka’s picture

What if you aren't using any page--front.tpl.php?

I've tried the solutions mentioned here and none worked.

I'm using Marinelli theme

constantinejohny’s picture

#29 works great, thanks!

pavlik.chmelar’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta7

I have solved it by changing settings at meta tag module configuration:

I disabled the rule for the type "Global: Front page" and added a new rule for my specific frontpage content type.

manoloka’s picture

pavlik.chmelar that is a way around to have a temporal solution but at some point you'll will realize you need different tags for your front page

RgnYLDZ’s picture

For those who tried everything here, and didn't find a solution; here's a half-hardcode solution:

in html.tpl.php in the head section, right before the title tag, you can add this;

<?php if ($is_front) :?>

/* here goes all metatags you want in your frontpage(whatever you set as frontpage). just write them manually */

<meta name="title" content="blablabla">
<meta name="description" content="blablabla">

<?php endif; ?>

BUT; don't include the title section into this. Because it's already rendered. You don't want double title tags in your front page. Well google doesn't ;)

kingfisher64’s picture

There is another solution to this. Use the metatag:context sub module and set the meta data path to <front> and reaction to meta data.

It does seem overkill though to have to enable context as well just to add a few lines of meta data.

Edit: Alternatively the same output can be achieved configuration > metatags > by path. This will only show with metatags:context enabled though.

DanNY’s picture

Found a quick and easy solution that shows meta tag description on page view source HTML for anonymous visitor, also Bing SEO Analyzer detects.

  1. Go to Meta Tag (Quick) settings from Configuration admin menu.
  2. Under the section Create and Attach, check box for Description for Taxonomy Term
  3. Click Attach
  4. Click Submit
  5. Go to admin Structure menu, Taxonomy, Section, List terms
  6. Edit Home to add a description in the (Meta) Description field.

Works

sadanand kenganal’s picture

Issue summary: View changes

Both will work.

If you have created any node for front page , this option will better.
render($page['content']);
or
other wise you can use,
render($page['content']['metatags']);

Thanks

PQ’s picture

I just had to deal with this and none of the solutions above worked because for some reason the metatags data was not present at all within $page['content'], $content or any other vars available in page.tpl.php or html.tpl.php when on the homepage. Therefore render($page['content']); etc did nothing.

In this instance I put the following in my theme's template.php file:

function THEMENAME_preprocess_page(&$vars) {
  if (!empty($vars['is_front'])) {
    metatag_page_build($vars['page']);
  }
}

(change THEMENAME for your theme name).

Interestingly metatag_page_build() does get called and correctly populates the metatag data into the $page array earlier in the requests execution, but that seems to have been removed by the time it gets to render the page.

This occurred on an Omega3 subtheme using a homepage-specific delta.

jeisses’s picture

I had the same issue in a new custom theme, #41 worked for me, thanks

zuernBernhard’s picture

#29 was the solution for me :)

cdonner’s picture

render($page['content']);
was present in my template. Only the context meta module with a rule for the <front> path worked for getting a meta description appear on my home page.

nibenon’s picture

this code

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

(by facine) works fine (with metatag module)

Samba B’s picture

#20 worked for me.. Saved my day today :)

artiprasad’s picture

First of all write following code to template of front page( page--front.tpl.php) :
render($page['content']['metatags']);

Then go through the following steps:
1) Go to yoursite/admin/config/search/metatags/config/global:frontpage or yoursite/admin/config/search/metatags/config/global%3Afrontpage page
2) Add page title description or other meta related description here
3) Save it
4) Clear the cache and your changes will reflect

Now you got the solution.

koddr’s picture

Thx for #47 solution. Worked for me!

raushan’s picture

Thanks #47 solution working fine.

argosbass’s picture

I had the same issue in a new custom theme ( OMEGA theme + CONTEXT-DELTA + METATAGS module ), #41 worked for me,

thanks

chegor’s picture

#41 works for me

jmart’s picture

Thank you #41! Using Zen subtheme.

hkarmy’s picture

The #45 solution, worked for me.

I have add following code on top of page.tpl.php

<?php
if($is_front) {
  render($page['content']['metatags']);
}
?>
herkimer’s picture

I hope this helps someone....and if not, then please delete this post.

I updated the "Site Frontpage" field from "node/30" to the URL-alias of the Front Page "province-hill". That caused the missing metatags to appear.

maxplus’s picture

Hi,
the only thing that worked for me was overriding admin/config/search/metatags/config/global%3Afrontpage
Adding the "render($page['content']['metatags']);" in my tpl file did not work

perarg’s picture

I confirm that solution #45 and ofcourse #53 is worked for me too. I use Superhero template

kundu’s picture

#29 Works!
Thank you!.. :)

codechefmarc’s picture

Another successful customer for #29. Thank you!

javier.martin’s picture

#29 works like a charm!!!!!!

Thanks to phlop.

andrezstar’s picture

Otherwise from template.php in your theme:
theme_html_head_alter ($vars){
}

rose5’s picture

What worked for me was to add the $head tag in html.tpl.php:
print $head;
Adding this added all the metatags I had defined in Configuration->Search and metadata->Metatag->Global: Front page

philsward’s picture

Removed comment due to outdated information.

fb-multimedia’s picture

Another solution to check :
In advanced settings see "Page region to use " :
"By default Metatag uses the 'Content' region to trigger output of the meta tags. Some themes do not have this region, so it can be necessary to pick another."
I didn't have content region on my homepage so I change this setting to 'header region' and it solve my issue.

chegor’s picture

#63 saved my day!

howdytom’s picture

Yeah. #63 saved my day too. Somehow I missed that setting. Thank you,fb-multimedia.

shital.mahajan’s picture

#20 is worked for me :)

iamfredrik’s picture

If you are using a node as front page, you need to disable "Global: Front page" under /admin/config/search/metatags

marttir’s picture

If you do as #67 says, be careful; it may hurt your front page SEO.

Disabling the "Global: Front page" metatag causes your front page metatags to use node urls of the format http://www.example.org/node/NID instead of the site url http://www.example.org/.

To work around that, you can manually set URL metatags to [site:url] on your front page node.

Sara101’s picture

#61 worked for me, thanks rose5. I tried all the suggestions of adding the render line to all my tpl pages and nothing worked. Im using bootstrap theme and my custom template is using html.tpl.php. Adding print $head; in my html.tpl.php worked.

divanova’s picture

I have a custom content type and a page from this content type is selected as a front page. This way the metatag module is not taking the values from this page, but from the "Global: Front page". I was trying for several hours to understand why this happens and I finally found a solution thanks to iamfredrik with his comment #67. Thanks iamfredrik, disabling the "Global: Front page" inside /admin/config/search/metatags worked!

AndraeRay’s picture

#63 fixed it for me. I had removed my content region from my front page.

Back From 7’s picture

#53 IS THE SOLUTION!