From 60792738113d412576e70b4a2e9177bbdf878beb Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Fri, 29 Apr 2022 08:59:14 -0700 Subject: [PATCH] Fix canonical URL redirects --- config.toml | 4 +++- layouts/partials/head.html | 13 +++++++------ layouts/partials/post-meta.html | 3 ++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/config.toml b/config.toml index 8d9321c..a0d8811 100644 --- a/config.toml +++ b/config.toml @@ -1,4 +1,4 @@ -baseURL = "https://seirdy.one/" +baseURL = "https://seirdy.one/" # just the default, I have mirrors languageCode = "en-us" title = "Seirdy's Home" @@ -13,6 +13,8 @@ disableKinds = ["taxonomy", "term"] [params] description = "Seirdy's Home: personal website and blog for Rohan Kumar, A.K.A. Seirdy" src = "https://sr.ht/~seirdy/seirdy.one/" +canonicalBaseURL = "https://seirdy.one" # I have mirrors with different baseURLs +webmentionEndpoint = "https://seirdy.one/webmentions/receive" logUrlPrefix = "https://git.sr.ht/~seirdy/seirdy.one/log/master/item/" copyright = "Copyright © 2021 Rohan Kumar" dark = "auto" diff --git a/layouts/partials/head.html b/layouts/partials/head.html index b77b2d5..02c4a94 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -1,15 +1,16 @@ +{{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" }} -{{ if or (eq site.BaseURL "https://seirdy.one/") (in site.BaseURL "wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion") -}} +{{ if or (eq site.BaseURL site.Params.CanonicalBaseURL) (in site.BaseURL "wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion") -}} {{ end -}} - - + + {{ $webmanifest := resources.Get "/manifest.webmanifest" | resources.ExecuteAsTemplate "manifest.webmanifest" . | resources.Minify | resources.Fingerprint "md5" -}} {{- printf `` $webmanifest.RelPermalink | safeHTML }} -{{ .Title }}{{ if and (lt (len .Title) 54) (ne .RelPermalink "/") }} - Seirdy{{ end }} +{{ .Title }}{{ if and (lt (len .Title) 54) (ne $canonicalRelPermalink "/") }} - Seirdy{{ end }} @@ -46,7 +47,7 @@ -{{- if not (or (ne "page" .Kind) (eq .RelPermalink "/bookmarks.html") (eq .RelPermalink "/posts.html")) }} +{{- if not (or (ne "page" .Kind) (eq $canonicalRelPermalink "/bookmarks.html") (eq $canonicalRelPermalink "/posts.html")) }} {{- end -}} @@ -55,7 +56,7 @@ - + {{ hugo.Generator }} diff --git a/layouts/partials/post-meta.html b/layouts/partials/post-meta.html index 0156ee4..df72837 100644 --- a/layouts/partials/post-meta.html +++ b/layouts/partials/post-meta.html @@ -1,5 +1,6 @@ +{{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" }} Posted - by {{- partial "indieweb-author.html" -}} on his Website{{- with .OutputFormats.Get "gemtext" -}}{{- printf " " -}}and Gemini capsule{{- end -}}. + by {{- partial "indieweb-author.html" -}} on his Website{{- with .OutputFormats.Get "gemtext" -}}{{- printf " " -}}and Gemini capsule{{- end -}}. {{ if lt .Date .Lastmod -}}
Last updated . Changelog.