File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 6
6
7
7
{{ $canonicalURL := .Permalink -}}
8
8
9
+ {{ $defaultLang := "en" -}}
10
+ {{ if and (ne .Language.Lang $defaultLang) .File -}}
11
+ {{/* This page is in a non-default-language section */ -}}
12
+ {{ $pagePath := strings.TrimPrefix (add hugo.WorkingDir "/content/") .File.Filename -}}
13
+ {{ if hasPrefix $pagePath $defaultLang -}}
14
+
15
+ {{/* This page is actually a default-language fallback page. Use the link
16
+ to the origin of the fallback page as canonical reference. */ -}}
17
+
18
+ {{ $translationPages := where .Translations "Lang" $defaultLang -}}
19
+ {{ $translation := index $translationPages 0 -}}
20
+ {{ with $translation -}}
21
+ {{ $canonicalURL = .Permalink -}}
22
+ {{ end -}}
23
+ {{ end -}}
24
+ {{ end -}}
9
25
< link rel ="canonical " href ="{{ $canonicalURL }} ">
10
26
11
27
{{- end -}}
You can’t perform that action at this time.
0 commit comments