I have recently migrated a site from D6 to D7 with the migrate module.
Everything has run pretty smoothly.
Now I am going through and adding the final touches but I cant for the life of me get the description meta tag to work on nodes (works on front page ok and I have over riden the default and set it to site slogan).
Tried it with the default token of summary, and tried overriding it with just some text. Still nothing.
Can anyone suggest something I am missing in order to get the description to work?
Has anyone else run into this problem?

Comments

cameron prince’s picture

I am seeing problems with description too. When using the default token of [node:summary], I have no description even though the body is populated. If I manually set a value for summary, I do see the metatag. If I replace [node:summary] with a fixed value I see the metatag.

DamienMcKenna’s picture

What version of Drupal core are you both using?

cameron prince’s picture

My issue turned out to be a problem with the summary token itself. The content had an image embedded with the media module that preceded the text. The summary token doesn't handle this well and returns nothing.

DamienMcKenna’s picture

@cameronbprince: You might try the Smart Trim module and a patch from #2372857: D7 - Trim excluding HTML (without stripping. to help with that.

2pha’s picture

Seems I have 2 sites where description is not working.
1 site is 7.34, the other is 7.37.
Both sites have there body field set as 'text area with a summary' but have summary input unchecked.
Output of the nodes with devel shows that the summary is an empty string.
Should the summary be an empty string?
Should the description token work even with an empty summary string?

The 7.37 site was migrated from D6 and some of the nodes do actually have a summary when views with devel, but these nodes still do not output a description meta.

To be honest I have never really take much notice of summaries on any sites as they have usually just worked.

cameron prince’s picture

@DamienMcKenna: I'm not understanding how Smart Trim would be a substitute for the summary token. Smart Trim is a field formatter.

DamienMcKenna’s picture

@cameronbprince: You'd need to customize the tokens and change the field to use that formatter.

cameron prince’s picture

I see where you're going... Use the token alter hook to replace the normal summary token output with output from rendering the body field with Smart Trim. Cool. I'll give that a shot.

DamienMcKenna’s picture

@cameronbprince: Or even just changing the "Token" view mode display settings for that content type.

cameron prince’s picture

You know, I always wondered what the "Tokens" option was for under display settings. Thanks for the tip. It works great and was way easier than using the token alter hook.

On a somewhat related note, for the Open Graph Image metatag, let's say I want to use an image constructed as: [site:url]sites/default/files/styles/large/public/profile.jpg

Is there a token to give me an itok token?

Something like: [site:url]sites/default/files/styles/large/public/profile.jpg[site:itok]

Without the itok, when an image that doesn't exist is requested, the result is an access denied error.

DamienMcKenna’s picture

erwangel’s picture

If you don't see any Description meta, verify that in the new settings page (7.x-1.5) under "Master controls for all entities" your content type is enabled, not just the type but also it's bundle.
I don't think this is a normal behavior:
1) If only content type is checked, it should apply to all bundles. If one doesn't want it global then he can check specific bundles. It seems to me more logical.
Also,
2) at least as I understood this up to now, the purpose of this setting is to have metatags available on a per node basis in the node's edit page. If I don't want to have such per node access, the global settings (Defaults page and its overrides) should apply anyway. It doesn't seem to be the case.

Well perhaps these are separate issues, not just applying to the description metatag. Need Damien's advise that my diagnostic is right before opening new issue ticket.

dan.mantyla’s picture

@erwangel that worked! thank you! problem solved.. for now. I do think this is a bug that should be fixed

DamienMcKenna’s picture

Status: Active » Closed (works as designed)

@danmantyla: The description meta tag is, by default, controlled on nodes by the [node:summary] token. If the summary only contains HTML then this is a site building problem and the site's architecture needs to be improved so that the token outputs actual text; you can confirm what the token will output by installing the Devel module, going to the Devel tab on a node and then going to the Token page.

After that there are a number of ways of adjusting the output - use Metatag's hooks to adjust the meta tags (see metatag.api.php for details), customize the Token display (go to the "Manage display" page for the entity bundle, enable the Token custom display, go to the new Token page and customize it as needed), etc. But removing HTML from the top of your content is out of scope for this module.

2pha’s picture

I can confirm what erwangel said in #12 that the bundle must be checked under "Master controls for all entities". Doing this did start outputting the description meta tag on new content. But, old content still does not display the description, even after updating the old content.