Skip to content

Commit 059d759

Browse files
committed
chore: cannonical link handling
Signed-off-by: Simon Schrottner <[email protected]>
1 parent cabf1c0 commit 059d759

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
{{ if in .RelPermalink "docs-v" -}}
3+
{{ $canoncical := replaceRE "-v[^/]+/" "/" .RelPermalink -}}
4+
{{ $canoncicalPath := substr $canoncical 0 -1 -}}
5+
{{ if .GetPage $canoncicalPath -}}
6+
<link rel="canonical" href="{{ $canoncical | absURL}}"/>
7+
{{ else }}
8+
{{ range .Site.Pages -}}
9+
{{ if in .Aliases $canoncical -}}
10+
<link rel="canonical" href="{{ .RelPermalink | absURL}}"/>
11+
{{- end }}
12+
{{- end}}
13+
{{- end}}
14+
{{ else if in .RelPermalink "/docs/" -}}
15+
<link rel="canonical" href="{{ .RelPermalink | absURL}}"/>
16+
{{- end}}

0 commit comments

Comments
 (0)