hreflang

Search engines use <link rel="alternate" hreflang="" href=""> tags to serve the correct language or regional URL in search results.

Hreflang is a simple module that automatically adds these tags to your pages, based on your site's enabled languages and the language switch links provided by core.

More info about hreflang can be found at the article Use hreflang for language and regional URLs.

A few days after installing this module, you should see a message reading "Currently, your site has no hreflang tag errors" at Google Webmaster Tools.

Take a look at the source code of this site to see the module in action.

The core Content Translation module adds hreflang tags only on content entity pages. This module, on the other hand, adds hreflang tags to all pages, and can be configured to defer to Content Translation module on content entity pages. If for some reason you'd like to modify the hreflang tags on a page, you can do so by implementing hook_language_switch_links_alter() or hook_page_attachments_alter() in a site-specific custom module.

Drupal 7

This module has no dependencies, but works well with Entity Translation module. If for some reason you'd like to modify the hreflang tags on a page, you can do so by implementing hook_language_switch_links_alter() or hook_html_head_alter() in a site-specific custom module.

Credits:

This module is developed and maintained by mfb. You can support development by contributing or sponsoring.

Alternatives and similar modules:

The Metatag: Hreflang module allows tokens to be entered to set the hreflang tags, but doesn't do that (or anything) automatically. This module adds the hreflang tags automatically.

Ports:

This project has been ported to Backdrop CMS and Drupal 6 LTS.

Supporting organizations: 

Project information

Releases