Hello,
some analyzing tools say, that the meta tag "language" is important and suggest to fix on a website, which is missing it.

Something like that: <meta name="language" content="de,de-at,de-ch" />

Is there a reason that this meta tag is not available? If not, I would like to request it's addition.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

akcakaya’s picture

Hello,

I need language meta tag for SEO in my website. How can i add Language meta tag?

Regards,

marcoka’s picture

+1, even if i have the opinion that google ignores this and analyzes the text (text analyze shows it the language). other opinions?

colan’s picture

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

Feature requests go into HEAD.

DamienMcKenna’s picture

Component: User interface » Code
Sinan Erdem’s picture

Any progress on this?

Rar9’s picture

is this now in beta 5?

DamienMcKenna’s picture

Component: Code » Other tags
giannisr’s picture

Any progress or solution on this?

aschiwi’s picture

From this issue I assume this is not being worked on. So as usual, patches are welcome.

Michsk’s picture

Create a custom module (i called mine metatag_hacks) and add the following snippet in your module.module. It implements hook_metatag_info().

<?php
function metatag_hacks_metatag_info() {
    $info = array();
    
    $info['tags']['language'] = array(
        'label' => t('Language'),
        'description' => '',
        'class' => 'DrupalTextMetaTag',
        'group' => 'advanced',
    );
    
    return $info;
}
DamienMcKenna’s picture

@lasac: Or you could make a patch..

Michsk’s picture

Will do. Just saw that the snippet is not correct we need http-equiv='' and not name=''.

Michsk’s picture

Here is the patch.

Michsk’s picture

looks like the tabs are not converted to spaces. In drupal we use 2 or 4 spaces for a tab?

Michsk’s picture

Indents should be fixed.

Michsk’s picture

guess not

Michsk’s picture

And now...

Michsk’s picture

Last time.

Michsk’s picture

as a sidenote i would advice the following patch for this as well:
https://drupal.org/node/975116

This gives you language tokens.

DamienMcKenna’s picture

Status: Active » Needs review

Thanks for putting the effort into this patch, I'll review it later today.

BTW when you upload a patch you need to change the status to "Needs review" as that both triggers the automated test system and informs others that it's ready to be manually tested & reviewed too.

Michsk’s picture

Got it. Here is the final patch, others should be forgotton.

Status: Needs review » Needs work

The last submitted patch, metatag-content-language-1338612-20.patch, failed testing.

DamienMcKenna’s picture

There's one small thing that needs to be fixed - you have some hard tabs at the closing line of the $element definition.

Michsk’s picture

New patch.

Michsk’s picture

I must say tough that my hands are itching when i see metatag.inc. We really should have the new objects just define a different template in stead of copy-pasting the whole getElement() method.

If i can find the time i would like to have a look at refactoring the code a bit if you like.

DamienMcKenna’s picture

Status: Needs work » Needs review
DamienMcKenna’s picture

@Lasac: I'm always interested in seeing how others can help improve the module :)

Michsk’s picture

Glad this hasn't been committed yet. After taking a better look at the code the following patch will do all we need without creating a whole new object.

Michsk’s picture

Michsk’s picture

Issue summary: View changes

example wasn't visible, so surrounded it by the code-tags.

JordanMagnuson’s picture

FYI, missing meta language information is reported as a "Moderate" SEO compliance issue by Bing webmaster tools.

rondev’s picture

I tested it with #975116: Create a 'language' token type (D7) to get a token.
Seems OK.
I use [language:language-content] for content language in the Global section of Metatag.

DamienMcKenna’s picture

Issue summary: View changes
Status: Needs review » Needs work

This needs a description added to explain what the meta tag is for and what acceptable values are.

aprohl5’s picture

I went to add the description field for the "language-content" meta tag and, after reading the w3 documentation on the tag ( http://www.w3.org/International/questions/qa-http-and-lang ) learned that this tag is deprecated and should not be used. As an alternative, you should include the "lang" attribute in the tag, drupal 7 does this already on both translated and non translated sites. If you would like I can still make the fix to the description field on the patch.

aprohl5’s picture

Status: Needs work » Needs review
aprohl5’s picture

Assigned: Unassigned » aprohl5
DamienMcKenna’s picture

Status: Needs review » Fixed

Committed. Thanks everyone!

  • Commit d8b9ba7 on 7.x-1.x authored by Lasac, committed by DamienMcKenna:
    Issue #1338612 by Lasac, DamienMcKenna: Added the content-language meta...
DamienMcKenna’s picture

Assigned: aprohl5 » Unassigned

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

selinav’s picture

Excuse-me I have update with the RC2 version and I don't see the meta content language in my content pages.
Where should I set this ?

selinav’s picture

Hello after update to the 7x-1.5, the meta content language still doesn't display,

I've entered on the admin/config/search/metatags (Global) page the field
Content language= [metatag:content-language]

But on the source code, it doesn't appears.
What is the mistake ?

Best regards

DamienMcKenna’s picture

Any time you use a "metatag" token in a metatag that means that you want it to use another meta tag value in place of the current one, e.g. using [metatag:description] in og:description. You should be using [node:language] to display a node's language, or apply the patch from #975116: Create a 'language' token type (D7) to add a new token to show the current page's language.

Also, the fact that you're using [metatag:content-language] in the "content language" tag means that you're created a circular reference; this would have crashed older versions but 1.5 is able to identify these (to a degree) and now blow up your site :)

selinav’s picture

DamienMcKenna, thanks for the reply. I did not understand it is a circular reference.
If I use [node:language] it well works for node.
What is the token to use for the homepage ([current-page:query:?], views or taxonomy ?

Thanks in advance

DamienMcKenna’s picture

@selinav: You need to use the patch from #975116: Create a 'language' token type (D7), then you'll have a new token for the current language that could be used in the global settings.