octopress / multilingual

Write elegant multi-language Jekyll sites
MIT License
69 stars 15 forks source link

Proposal: support for rel="alternate" hreflang="x" #27

Open taringamberini opened 8 years ago

taringamberini commented 8 years ago

It would be nice if the generated translation_id would be used to generate alternate link in <head> section of a post.

Reason behind the proposal

Help search engines to serve the most appropriate (language) content.

Expected behaviour

Write an alternate_lang_link tag in the <head> section of a post layout:

<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  {% alternate_lang_link %}
  ...

the tag should search all posts which shares the same translation_id and than for each post it should generate a list of strings for each language like:

<link rel="alternate" hreflang="<POST_LANG>" href="<POST_URL>" />

If an it, en, de, multilingual site had posts at URLs like:

the generated posts should all contains:

<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  <link rel="alternate" hreflang="it" href="http://www.my-multilingual-site.com/it/blog/post-favoloso" />
  <link rel="alternate" hreflang="en" href="http://www.my-multilingual-site.com/en/blog/awsome-post" />
  <link rel="alternate" hreflang="de" href="http://www.my-multilingual-site.com/de/blog/geweldig-bericht" />
  ...

Thank you very much in advance for your help, Tarin