diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-30 12:55:27 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-30 12:55:27 +0200 |
| commit | 5ef13e5aa5ea565b07441616ab1eece565aa2f53 (patch) | |
| tree | b34276c2537061e55d2cfdf7824fc713619f9230 /app/views/layouts | |
| parent | 60c3671b6f09f1f4d4a7d30216c94a80dbee6baa (diff) | |
Canonicalise per locale and declare hreflang alternates
German content is reachable at both /updates/foo and /de/updates/foo,
and a page with no English translation renders German at
/en/updates/foo through the fallback chain, so three URLs each
claimed to be canonical. Both tags now derive from one
locale-to-URL function, which points every duplicate at the address of
the version actually served, the unprefixed German URL, matching
default_url_options.
Alternates are declared only for locales in which the page genuinely has
a translation, since /en/ serving German through the fallback is not an
English version of the page. x-default points at German, the site's
primary language.
Diffstat (limited to 'app/views/layouts')
| -rw-r--r-- | app/views/layouts/_social_meta.html.erb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/app/views/layouts/_social_meta.html.erb b/app/views/layouts/_social_meta.html.erb index 9a86d26d..36547d26 100644 --- a/app/views/layouts/_social_meta.html.erb +++ b/app/views/layouts/_social_meta.html.erb | |||
| @@ -23,6 +23,13 @@ | |||
| 23 | <meta property="og:locale:alternate" content="<%= alternate %>"/> | 23 | <meta property="og:locale:alternate" content="<%= alternate %>"/> |
| 24 | <% end %> | 24 | <% end %> |
| 25 | 25 | ||
| 26 | <% if (hreflang_alternates = og_hreflang_alternates).any? %> | ||
| 27 | <% hreflang_alternates.each do |code, url| %> | ||
| 28 | <link rel="alternate" hreflang="<%= code %>" href="<%= url %>"/> | ||
| 29 | <% end %> | ||
| 30 | <link rel="alternate" hreflang="x-default" href="<%= og_locale_url(I18n.default_locale) %>"/> | ||
| 31 | <% end %> | ||
| 32 | |||
| 26 | <% if og_published_time %> | 33 | <% if og_published_time %> |
| 27 | <meta property="article:published_time" content="<%= og_published_time %>"/> | 34 | <meta property="article:published_time" content="<%= og_published_time %>"/> |
| 28 | <% end %> | 35 | <% end %> |
