Skip to content

Instantly share code, notes, and snippets.

@bovender
Forked from waissbluth/_hreflang.html.haml
Last active May 8, 2017 09:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bovender/efbea6314e7f0e84b4265bba10094942 to your computer and use it in GitHub Desktop.
Save bovender/efbea6314e7f0e84b4265bba10094942 to your computer and use it in GitHub Desktop.
Ruby on Rails SEO. Add a <link rel="alternate" hreflang="es" href="http://es.example.com/" /> link to every other locale for the same page. Per https://support.google.com/webmasters/answer/189077?hl=en
-# For each locale except the current one
- I18n.available_locales.each do |locale|
-# Add a link to the current URL but in `locale` language
%link{rel: 'alternate', hreflang: locale, href: url_for(locale: locale, only_path: false)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment