Meta tags completely does not work at my site. Do I need to activate it somewhere?

What I did:
- Install API and UI (did not install Open Graph)
- Added a Meta Tag default for a specific node type
- Changed title to a fix word
- Enabled all checkboxes in "Advanced" (I want to hide that nodetype completely)
- Clicked "Save" and got this Warning: Warning: htmlspecialchars() expects parameter 1 to be string, array given in check_plain() (line 1332 of C:\Users\std.BBT\Documents\xampp\htdocs\eeschweiz\drupal\eeschweizd7\includes\bootstrap.inc).
- Looked at a node of that type: The page title did stil show up and also the meta tags.
- Cleared the Cache: Same result
- Disabled all checkboxes in "Advanced", only the title is now set to "something". The Warning is disabpeard.
- Cleared the Cache: The title is not "something", but is the page title. (Which I actually want to hide)

So: Any idea what the problem is?

CommentFileSizeAuthor
#16 Untitled-1.jpg322.47 KBAnonymous (not verified)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

majorbenks’s picture

Version: 7.x-1.0-alpha2 » 7.x-1.0-alpha3

I tested this also with the alpha 3. Same result.

So I tried to override the node template. And for all nodes it works fine, except one node type. This nodetype uses an extra tpl.php, so I assume thats the problem! As soon as I override a nodetype, the modul is no longer working properly.

Dave Reid’s picture

Status: Active » Postponed (maintainer needs more info)

What theme are you using? Are you using Display Suite at all or some module that alters the output of nodes? Because the module "outputs" its meta tags inside the node some themes do not properly use render() and will skip output of metatags.

farfanfelipe’s picture

Status: Postponed (maintainer needs more info) » Active

I am using the ZEN theme but I think that is not a problem related with the theme. After many tests I have the problem when I override the page.tpl.php, the metatags do not show up.

For example: I have a page--front.tpl.php for my homepage, in this case any metatag show up. But, I have a static page that uses the page.tpl.php, in this case the metatags work perfectly.

Dave Reid’s picture

Probably because your page--front.tpl.php doesn't call render($page['content']); I will guess.

farfanfelipe’s picture

No, I included all type's of render and and it does not work!

Dave Reid’s picture

Can you PrivatePaste your page--front.tpl.php?

Buckminster_Bond’s picture

Had the same issue (metatags working everywhere, but not the front page) - #4 was the culprit. Thanks Dave!

farfanfelipe’s picture

Here it is - http://privatepaste.com/537796820e/gokiko

I checked and I see that the variables has been set in the node array for the metatag module but I could not track when It assign the values to the $page[] variable. Thank's Dave Reid!

Anonymous’s picture

I have the same problem. The meta tags show fine on basic pages but the content type which I'm rendering via Display Suite misses out some of the meta tags (the Drupal 7 generator meta is fine).

For what it's worth; $variables on line 14 of metatag.theme.inc only contains the generator not all the meta tags I would expect. I also can't find where you are calling that theme_metatag from.

ELS Landscape’s picture

Having a similar issue with the index page not generating tags.
Using Danland theme an it only has page.tpl.php and I do not see a front.tpl.php in that theme.

I did create a landing page using the wizard in pages with Ctools. I think that is the mod that has the pages wizard.
I searched for a different template but don't see it.

And, the page wizard is not mess with the danland theme for the front page which seems to be all done from single page.tpl.php.

Edit - more investigation shows the front page made with view likely has the theme from views-view.tpl.php

Still not getting on the home page unless I log in but most search engines will not log in lol.
It is showing up on all other pages logged in or not.

greenerr’s picture

I edited the global tags for my site. The DO NOT work for the main page but do work on every other page. I edited the global: front page tags with the same result.

Any thoughts?

Anonymous’s picture

I found the solution to my problem here - http://drupal.org/node/1284852

Patch on comment #6 works for me.

ELS Landscape’s picture

I am not running display suite but I am sure it has to do with whatever template is being generated not calling up the content.

majorbenks’s picture

The title hidding is now working. I did not call render page[content].

But I have still two issues: First, I get this message as soon as I enable the robot preventions: "Warning: htmlspecialchars() expects parameter 1 to be string, array given in check_plain() (line 1521 of /home/httpd/vhosts/eemission.ch/subdomains/neu/httpdocs/includes/bootstrap.inc)."
But I don't know, if this message has any consequence.

Second: When I look at the page source (via my browser) I still see the title in a meta content:
(TestMetaTags is the title of the Node) Isn't it possible to turn this completely off?

andrenoronha’s picture

Like #11 it works on every page except for front page.
I unset the content on front page via preprocess_page:

if (drupal_is_front_page()) {
	unset($variables['page']['content']['system_main']['nodes']);
	unset($variables['page']['content']['system_main']['pager']);
}

I tested with and without it and it's the same.

Anonymous’s picture

Priority: Normal » Major
FileSize
322.47 KB

I still have this very annoying issue. With me it's not working on a custom content type, wich is displayed in a variant (panels) that is selected on this content type. It is working on all pages, except this page.
I also get the error "Warning: htmlspecialchars() expects parameter 1 to be string, array given in check_plain() (line 1332 of includes/bootstrap.inc)."".
Meta tags quick are not working either.

At the meta tag settings page, the robots settings are not listed. See this image:
screenshot

Dave Reid’s picture

There is no working integration with panels yet. See #1151938: Panels integration - meta discussion. The PHP notice has already been fixed with #129664: Add setting to disable auto URL aliases for project nodes.

Anonymous’s picture

That Post seems to be only for Drupal 6.x.

andrenoronha’s picture

For any reason after 3 hours or so, it started working.

Anonymous’s picture

What started working? Cache expired ;)?

andrenoronha’s picture

I guess it wasn't cache, cause I had cleaned cache before. And had try running cron manually.
Such a mistery....... o.o

nicolailai’s picture

Probably because your page--front.tpl.php doesn't call render($page['content']); I will guess.

#4 Thank you for the tip!
I just placed "render($page['content'])" in two different page--front.tpl.php I've created. And it works.
The metatag module checks for it with an if statement. If it's not set it will return nothing... NOOOTHING!! :-)

Kristen Pol’s picture

I'm having the same problem with alpha4 and bartik theme on D7.9 which does have the proper render function. I have cleared the cache several times. I do have the locale module turned on though and I know there is supposed to be some issue with multilingual sites and metatag but I figured it would show one set of meta tags for all the localized nodes so I was just testing it. But, it doesn't show any of my custom node meta tags.

[update 12/27/11] I created a new content type with translation and named 2 nodes the same alias (English & French) and the custom meta tags show up for those 2 pages. They do not show up for 3 nodes with the same alias that are for node type = 'page'... So, I don't know if this is localization-related or something else entirely.

[update #2] I created more content of content type 'page' and those show the custom meta tags. So... my only guess at this point is that content that was added before turning on the metatag module isn't showing the custom meta tags though that seems weird. Maybe there is something else about those 3 nodes that isn't obvious.

Kristen

SergO’s picture

#4, #22 - It works for my Zen-subtheme, thanks.

GNA27’s picture

The Meta Tag module does not work on my site either. I am using the Jackson theme.

All page titles default to the title in the content type. No descriptions appear in the page source code, and titles do not change despite modifying them by node types in the module.

I have no idea why this is happening. Can someone please post simple instructions that will correct this? I am a relative beginner with Drupal, and I am not very familiar with PHP coding. All I've ever done is edit snippets based on support responses.

So, please, I need something SIMPLE that doesn't require much coding expertise. It always boggles my mind that there is so much customization required just to make some modules and themes functional and useful. The Drupal community desperately needs universal standardization and to start following quality management and control models used in the development of other products.

Kristen Pol’s picture

Title: Meta tags does completely not work at my site. » Meta tags completely does not work at my site
David_Rothstein’s picture

This issue is kind of all over the place, but note that one possible explanation for Meta tags not working at all on a site (although a relatively unlikely one) is this: #1434288: Metatags aren't rendered if there are no blocks in the "Content" region

khburres’s picture

I confirm the problem specified at the link provided in #27 worked for me.
Instead of the patch, I simply created an empty block for the content area that only displayed on the front page (<front>). Then when I added
<?php render($page['content']); ?>
the meta tags displayed.

cblanglois’s picture

Hello all! I am in the same quandary----ALL MY META TAGS DON'T WORK EXCEPT the front page. What's wrong?

Help would be appreciated.

The solutions provided here have to do with meta tags not working EXCEPT the front page. Mine's the opposite.

Also, there are, in fact, two block in the content region. So that solution doesn't suit me. Help! :)

DamienMcKenna’s picture

We need to review this more thoroughly before the stable release.

Dave Reid’s picture

Version: 7.x-1.0-alpha3 » 7.x-1.x-dev
Category: bug » task

Going to move this to a task for now since it's obvious that this does work for some and not for others. It depends on what theme is being used and if it properly renders content.

FrancescoUK’s picture

Striking factor is Page Titles is able to add the right title to the front page without fiddling with template or php.

Anonymous’s picture

There are hundred other ways to achieve that without touching templates...

rovo’s picture

In reply to:
http://drupal.org/node/1293214#comment-5084258

Thanks for this hint, this was the issue for me.

I was thinking it would render through print $head;

b0b’s picture

I also had this issue. But all my page.tpl files had render($page['content']); in them and the Main page content block was in the Content area.

It turned out to be some custom node.tpl files I had created that caused the problem. Adding print render($content); at the bottom of my node.tpl files fixed it for me.

Anonymous’s picture

Hello, I created some custom template without the "render($page['content']);", this cause the meta tags to disappear.

I've got 2 questions based on that fact:

1) Is it wrong to not call "render($page['content']);" in a template file?

2) Is there a way to call the meta description, meta tags and title in the template.php to avoid this issue?

Thank you for your help! Great Module!

gonz’s picture

We are in the same boat - we are still on the uphill part of the learning curve when it comes to Drupal 7 theming (coming from 4-5-6)

We still build node--xxxx.tpl.php files (albeit well organized and pretty complex using entity reference fields and deep rooted field collection data strings)

Problem is we never really render full content either. We build out designs and inject fields and other variables as content into our theme.

This obviously presents the huge problem of no Meta Tags Module.

I gotta have it. SEO is too important. We tried adding the render content snippet and sure enough - it worked like a charm, but added dupe content to my page. No Bueno.

Any advice?

b0b’s picture

I did not get duplicate content when I added the render snippet. Did you put it at the bottom, below the manually rendered fields? I thought render does not include any content that has already been called manually.

Anonymous’s picture

#37: I think so far the best solution is to call the "render($page['content'])" function and then manually hide all the custom fields in Structure -> Content Types -> Manage fields.

Once this is done, you can call all your customs fields manually in the .tpl file with $node->myCustomField[array].

I don't know if this is the best way to do but it works for sure.

gonz’s picture

You're right - they were not duplicates. On further inspection they were fields that ran through for each loops in my tpl

What you said about not rendering twice is right on the money - starting to gain clarity. Thanks b0b

I wound up using the hide method to directly call out to those fields that were still showing up on my page.

<?php
hide($content['field_artist_link']);
hide($content['field_artist_members']);
hide($content['field_artist_music_samples']);
hide($content['field_artist_twitter']);
hide($content['field_artist_term']);
print render($content);
?>

Seemed to work great.

Turns out - only global defaults were working - so after reading another thread, I grabbed the latest DEV and now my custom metatags are fully functional. Stoked.

So is that the trick these days? Hide eveything -> Call render. Then Manually add them render them back into the page. Is there a preference to put the render at the top or bottom of the tpl? (I know that's a themer question for another thread - just thought I would try to squeeze one last bit of advice :)

kumkum29’s picture

Thanks Pairodime,

I followed your solution. The metas are working well. But the solution is not very clean. Is there a module patch to avoid copy this code at the bottom of page?

Thanks.

ThePeach’s picture

Had the same issue and I totally agree on what pairodime said in #37 and #40.

The solution is dirty and I can confirm that it works.

stickybeatz’s picture

<?php
print render($content['metatags']);
?>

works for those of us who do not want to use print render($content);

I put it at the bottom of node.tpl.php and all custom node tpl files

DamienMcKenna’s picture

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.

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.

poorva’s picture

print render($page['content']['metatags']);
It works for me...

DamienMcKenna’s picture

Status: Postponed (maintainer needs more info) » Fixed

This should work now, between the hook_entity_view change in #1363476: Panels integration - ensure meta tags work OOTB on entity pages, a matching change in the core logic in #1784896: Overriding meta tags fall back to parent default tag value and a stop-gap work-around for a missing hook for taxonomy term pages in #1700160: Support taxonomy term pages until taxonomy supports hook_entity_view(). If you are still having a problem specifically with the front page 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)
DamienMcKenna’s picture

Issue summary: View changes

Fix grammar

sujoyit2005’s picture

Issue summary: View changes

A great tip by Dave Reid #4.

Putting render($page['content']); line of code somewhere on the page--front.tpl.php, (preferably after all the necessary content is printed on the page) solved the problem. Now, as the other pages of the website, HOME page also shows META Description and Keywords where website is using Metatag module.

Thanks Dave.