Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#26 | metatag-n1386320-26.patch | 889 bytes | DamienMcKenna |
#24 | metatag-n1386320-23.patch | 849 bytes | DamienMcKenna |
#14 | metatag-no-content-missing-metatags-1386320-14.patch | 605 bytes | arpieb |
Comments
Comment #1
PazZze CreditAttribution: PazZze commentedI'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
Comment #2
hles CreditAttribution: hles commentedI 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.
Comment #3
hles CreditAttribution: hles commentedWell, 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.
Comment #4
mrmeech CreditAttribution: mrmeech commentedI 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.Comment #5
enrikito CreditAttribution: enrikito commented+1
Comment #6
_gramur CreditAttribution: _gramur commentedIs there any kind of work around for those who don't use
For example if a front page uses custom regions which relies on Views?
Comment #7
mrmeech CreditAttribution: mrmeech commentedIf 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:
Comment #8
swfindlay CreditAttribution: swfindlay commentedIf 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
Comment #9
jisuo CreditAttribution: jisuo commentedAnd exactly what should you print in html.tpl.php?
Comment #10
Shaltay CreditAttribution: Shaltay commentedSame here.
I m using danblog theme
overwriting html.tpl.php does not work for me.
Comment #11
Danny EnglanderI believe this is similar to or a duplicate of: Front Page Meta Description
Comment #12
davidtrainer CreditAttribution: davidtrainer commentedIf you are using zen, you may want to check out #1551340: $page['content'] is missing in hook_page_build.
Comment #13
marcoka CreditAttribution: marcoka commentedso 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.
Comment #14
arpieb CreditAttribution: arpieb commentedWe'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:
The attached patch simply creates an empty $page['content'] element instead of returning so normal metatag processing can take place.
Comment #15
DamienMcKennaRather 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.
Comment #16
DamienMcKennaRelated 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.
Comment #17
DamienMcKennaThis 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).
Comment #18
DamienMcKennaComment #19
mustafa.ata CreditAttribution: mustafa.ata commentedSOLUTION:
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:
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
Comment #20
DamienMcKenna@Ata: Does it work if you do
render($page['content']['metatags']);
?Comment #21
willvincent CreditAttribution: willvincent commentedrender($page['content']['metatags']);
Fixes it for me with beta2
Comment #22
mustafa.ata CreditAttribution: mustafa.ata commentedYes Damien, it also worked for me.
Are you getting any issue?
Thanks
Ata
Comment #23
DamienMcKennaMarked #1941362: Important to state clearly somewhere that if $page['content']['metatags'] isn't rendered by th theme then nothing will happen as a duplicate. Also, this is a documentation task now.
Comment #24
DamienMcKennaThis adds the following lines to the Known Issues section of the README.txt file:
I've also renamed the Known Issues section to "Troubleshooting / Known Issues" to help draw attention to it.
Comment #25
DamienMcKennaClosed another duplicate: #1941638: page--front.tpl.php
Comment #26
DamienMcKennaA small update that gives an example of a template file's filename.
Comment #27
DamienMcKennaCommitted.
Comment #28
DamienMcKennaNow that Metatag v7.x-1.0-beta5 is out am closing this to keep the issue queue clean.
Comment #29
pkhlop CreditAttribution: pkhlop commented* 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
Comment #30
dpjef CreditAttribution: dpjef commentedHad 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.
Comment #31
airstarh CreditAttribution: airstarh commented#29 helps!
Thank you!.. But why...
Comment #32
fahadurrehman CreditAttribution: fahadurrehman commentedI 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.
Comment #33
manoloka CreditAttribution: manoloka commentedWhat 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
Comment #34
constantinejohny CreditAttribution: constantinejohny commented#29 works great, thanks!
Comment #35
pavlik.chmelar CreditAttribution: pavlik.chmelar commentedI 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.
Comment #36
manoloka CreditAttribution: manoloka commentedpavlik.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
Comment #37
RgnYLDZ CreditAttribution: RgnYLDZ commentedFor 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;
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 ;)
Comment #38
kingfisher64 CreditAttribution: kingfisher64 commentedThere 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.
Comment #39
DanNY CreditAttribution: DanNY commentedFound a quick and easy solution that shows meta tag description on page view source HTML for anonymous visitor, also Bing SEO Analyzer detects.
Works
Comment #40
sadanand kenganal CreditAttribution: sadanand kenganal commentedBoth 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
Comment #41
PQ CreditAttribution: PQ commentedI 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:
(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.
Comment #42
jeisses CreditAttribution: jeisses commentedI had the same issue in a new custom theme, #41 worked for me, thanks
Comment #43
zuernBernhard CreditAttribution: zuernBernhard commented#29 was the solution for me :)
Comment #44
cdonner CreditAttribution: cdonner commentedrender($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.Comment #45
nibenon CreditAttribution: nibenon commentedthis code
(by facine) works fine (with metatag module)
Comment #46
Samba B CreditAttribution: Samba B commented#20 worked for me.. Saved my day today :)
Comment #47
artiprasad CreditAttribution: artiprasad commentedFirst 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.
Comment #48
koddr CreditAttribution: koddr commentedThx for #47 solution. Worked for me!
Comment #49
raushan CreditAttribution: raushan commentedThanks #47 solution working fine.
Comment #50
argosbass CreditAttribution: argosbass commentedI had the same issue in a new custom theme ( OMEGA theme + CONTEXT-DELTA + METATAGS module ), #41 worked for me,
thanks
Comment #51
chegor CreditAttribution: chegor as a volunteer commented#41 works for me
Comment #52
jmart CreditAttribution: jmart commentedThank you #41! Using Zen subtheme.
Comment #53
hkarmy CreditAttribution: hkarmy commentedThe #45 solution, worked for me.
I have add following code on top of page.tpl.php
Comment #54
herkimer CreditAttribution: herkimer commentedI 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.
Comment #55
maxplus CreditAttribution: maxplus commentedHi,
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
Comment #56
perarg CreditAttribution: perarg commentedI confirm that solution #45 and ofcourse #53 is worked for me too. I use Superhero template
Comment #57
kundu CreditAttribution: kundu as a volunteer commented#29 Works!
Thank you!.. :)
Comment #58
codechefmarc CreditAttribution: codechefmarc as a volunteer commentedAnother successful customer for #29. Thank you!
Comment #59
javier.martin CreditAttribution: javier.martin commented#29 works like a charm!!!!!!
Thanks to phlop.
Comment #60
andrezstar CreditAttribution: andrezstar commentedOtherwise from template.php in your theme:
theme_html_head_alter ($vars){
}
Comment #61
rose5 CreditAttribution: rose5 commentedWhat 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
Comment #62
philsward CreditAttribution: philsward commentedRemoved comment due to outdated information.
Comment #63
fb-multimediaAnother 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.
Comment #64
chegor CreditAttribution: chegor as a volunteer commented#63 saved my day!
Comment #65
howdytom CreditAttribution: howdytom as a volunteer commentedYeah. #63 saved my day too. Somehow I missed that setting. Thank you,fb-multimedia.
Comment #66
shital.mahajan CreditAttribution: shital.mahajan commented#20 is worked for me :)
Comment #67
iamfredrik CreditAttribution: iamfredrik commentedIf you are using a node as front page, you need to disable "Global: Front page" under /admin/config/search/metatags
Comment #68
marttir CreditAttribution: marttir at Avoltus Oy commentedIf 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.
Comment #69
Sara101 CreditAttribution: Sara101 commented#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.Comment #70
divanova CreditAttribution: divanova commentedI 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!
Comment #71
AndraeRay CreditAttribution: AndraeRay as a volunteer commented#63 fixed it for me. I had removed my content region from my front page.
Comment #72
Back From 7 CreditAttribution: Back From 7 commented#53 IS THE SOLUTION!