Browse Source
The canonical link and the noindex meta tag were never emitted on the english articles published as-is in the french site, because head.html was checking the language detection of the translation instead of the current page. Hence, the original articles also advertised the french copies as their translation through hreflang. - emit canonical + noindex on the french copies (68 pages) - only list real translations in hreflang, including the current page - exclude the french copies from the sitemap and its alternates - restrict the language detection to regular pages: list pages have no file and an empty content, hence they were always detected as copies Refs #11 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YNHsWYTXPThURz6TbVS1j3master
4 changed files with 57 additions and 6 deletions
@ -0,0 +1,32 @@ |
|||||
|
{{- /* |
||||
|
-- Based on the Hugo embedded sitemap template (v0.121.2). |
||||
|
-- |
||||
|
-- The english articles published as-is in the french site are excluded |
||||
|
-- from the sitemap and from the list of alternates, since they are |
||||
|
-- duplicates of the original articles. |
||||
|
*/ -}} |
||||
|
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }} |
||||
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" |
||||
|
xmlns:xhtml="http://www.w3.org/1999/xhtml"> |
||||
|
{{ range $page := .Data.Pages }} |
||||
|
{{- partial "lang-detection.html" . -}} |
||||
|
{{- if and .Permalink (not (.Scratch.Get "en_article_in_fr_site")) -}} |
||||
|
<url> |
||||
|
<loc>{{ .Permalink }}</loc>{{ if not .Lastmod.IsZero }} |
||||
|
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }} |
||||
|
<changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }} |
||||
|
<priority>{{ .Sitemap.Priority }}</priority>{{ end }}{{ with partial "real-translations.html" . }}{{ range . }} |
||||
|
<xhtml:link |
||||
|
rel="alternate" |
||||
|
hreflang="{{ .Language.LanguageCode }}" |
||||
|
href="{{ .Permalink }}" |
||||
|
/>{{ end }} |
||||
|
<xhtml:link |
||||
|
rel="alternate" |
||||
|
hreflang="{{ $page.Language.LanguageCode }}" |
||||
|
href="{{ $page.Permalink }}" |
||||
|
/>{{ end }} |
||||
|
</url> |
||||
|
{{- end -}} |
||||
|
{{ end }} |
||||
|
</urlset> |
||||
@ -0,0 +1,12 @@ |
|||||
|
{{- /* |
||||
|
-- Returns the translations of a page, excluding the english articles |
||||
|
-- published as-is in the french site (they are not real translations). |
||||
|
*/ -}} |
||||
|
{{- $translations := slice -}} |
||||
|
{{- range .Translations -}} |
||||
|
{{- partial "lang-detection.html" . -}} |
||||
|
{{- if not (.Scratch.Get "en_article_in_fr_site") -}} |
||||
|
{{- $translations = $translations | append . -}} |
||||
|
{{- end -}} |
||||
|
{{- end -}} |
||||
|
{{- return $translations -}} |
||||
Loading…
Reference in new issue