Skip to content

Commit 70f6cc9

Browse files
authored
add canonical link tags for all pages (#28)
Add canonical link tags in the base template. Use .Permalink as the source and strip a trailing .html suffix so canonical URLs are extensionless (e.g. /architecture). Prefer extensionless canonical URLs because they are shorter and cleaner, while the .html variants remain valid and accessible on GitHub Pages. Canonical tags tell search engines which URL is authoritative, reducing duplicate-URL ambiguity for indexing and ranking. This approach is chosen in favor of meddling with `uglyURLs` to retain compatibility with already-existing links out there on the intertubes.
2 parents e4f7dd1 + da615c2 commit 70f6cc9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

layouts/_default/baseof.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<title>{{ .Title }}</title>
7+
{{- $canonical := .Permalink | replaceRE "\\.html$" "" -}}
8+
<link rel="canonical" href="{{ $canonical }}">
79
<link rel="icon" href="{{ relURL "favicon.ico" }}">
810
{{- $style := resources.Get "sass/main.scss" | resources.ExecuteAsTemplate "main.scss" . | css.Sass }}
911
<link rel="stylesheet" href="{{ $style.RelPermalink }}">

0 commit comments

Comments
 (0)