When a node has 1 or many translation, it could be useful to tell the search engine about their existence adding alternate links tag on html head, those alternate links are invisible to humans but very helpful to for search engines to organize the multilingual website structure (See this post on Google Webmaster Central blog.

If we have a node in Spanish translated to English and French (and both languages enabled), I18n module should provide these links on html head:

<link rel="alternate" type="text/html" href="url-of-english-node"  hreflang="en" title="The english node title" />
<link rel="alternate" type="text/html" href="url-of-french-node"  hreflang="fr" title="The french node title" />

And so for english and french nodes...

It would be like the language switcher but for search engines

CommentFileSizeAuthor
#4 alternate.zip7.14 KBgustavol
#3 alternate.zip7.14 KBgustavol

Comments

dropbydrop’s picture

Title: Alternate language link tag in header » hreflang support
Component: Code » Blocks
opi’s picture

A small gist for Drupal6 implementation. The method may be the same for Drupal7
https://gist.github.com/1437730

gustavol’s picture

StatusFileSize
new7.14 KB

I've made a simple module for 6.x, named alternate with the code posted in git which solves the hreflang support. I've tested it and works. I don't know how to post it as a module. If someone would like to help on posting it to as a project, please feel free to do it.
Compressed code is attached.
thanks.

gustavol’s picture

StatusFileSize
new7.14 KB

I forget the attach

opi’s picture

GustavoL, thanks for "packaging" as a module. I'm able to post it as a module, but I wonder if it could be attached with an existing module. Maybe i18n, maybe a seo-related module ... Let's discuss it before jumping into creating another tiny module ...

jose reyero’s picture

Status: Active » Needs work

Yes, this looks good.

How about a i18n_hreflang module?

Still, I'm wondering whether we should add it into i18n or create another one (sth like 'i18n_seo') for this and some other small modules (like i18n_redirect).

Btw, what do we need that install file for?

opi’s picture

Jose, you're right, the .install file is useless in our case.

Maybe this could be a part of meta-tags ?
- you could have i18n, but don't care about seo
- If you care about seo, you might have Meta-tags (?)

I'm probably wrong, and this feature is only i18n-related. In this case, an i18n_seo (sub)module seems a good choice for me. ( More global than an i18n_hreflang )

jose reyero’s picture

@opi,

I think both options make sense, though if we prepare it to work with i18n we can translate a few more paths, and also provide translated titles.

Related, may be used for this, #1387012: API function to get path translations, repurpose hook_i18n_translate_path()

jose reyero’s picture

no2e’s picture

jose reyero’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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