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
Comments
Comment #1
dropbydrop commentedNecessary for good SEO.
http://googlewebmastercentral.blogspot.com/2011/12/new-markup-for-multilingual-content.html
Comment #2
opiA small gist for Drupal6 implementation. The method may be the same for Drupal7
https://gist.github.com/1437730
Comment #3
gustavol commentedI'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.
Comment #4
gustavol commentedI forget the attach
Comment #5
opiGustavoL, 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 ...
Comment #6
jose reyero commentedYes, 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?
Comment #7
opiJose, 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 )
Comment #8
jose reyero commented@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()
Comment #9
jose reyero commentedSee http://drupal.org/sandbox/reyero/1389424
Comment #10
no2e commentedRelated (but for D8 core):
#1164682: links with a known language need language identifier
And a current core limitation:
#1435936: drupal_add_html_head_link() will not allow you to add more links with the same rel value
Comment #11
jose reyero commentedNew module here, http://drupal.org/project/i18n_contrib