1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-11-27 14:12:09 +00:00

Fix canonical URL redirects

This commit is contained in:
Rohan Kumar 2022-04-29 08:59:14 -07:00
parent cb2337fb0f
commit 6079273811
No known key found for this signature in database
GPG key ID: 1E892DB2A5F84479
3 changed files with 12 additions and 8 deletions

View file

@ -1,4 +1,4 @@
baseURL = "https://seirdy.one/" baseURL = "https://seirdy.one/" # just the default, I have mirrors
languageCode = "en-us" languageCode = "en-us"
title = "Seirdy's Home" title = "Seirdy's Home"
@ -13,6 +13,8 @@ disableKinds = ["taxonomy", "term"]
[params] [params]
description = "Seirdy's Home: personal website and blog for Rohan Kumar, A.K.A. Seirdy" description = "Seirdy's Home: personal website and blog for Rohan Kumar, A.K.A. Seirdy"
src = "https://sr.ht/~seirdy/seirdy.one/" 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/" logUrlPrefix = "https://git.sr.ht/~seirdy/seirdy.one/log/master/item/"
copyright = "Copyright © 2021 Rohan Kumar" copyright = "Copyright © 2021 Rohan Kumar"
dark = "auto" dark = "auto"

View file

@ -1,15 +1,16 @@
<head> <head>
{{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" }}
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="disabled-adaptations" content="watch"><meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="disabled-adaptations" content="watch"><meta name="viewport" content="width=device-width, initial-scale=1.0">
{{ 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") -}}
<meta name="robots" content="index,follow,max-image-preview:large,max-snippet=-1"> <meta name="robots" content="index,follow,max-image-preview:large,max-snippet=-1">
{{ end -}} {{ end -}}
<link href="https://seirdy.one{{ .RelPermalink }}" rel="canonical"> <link href="{{ .Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}" rel="canonical">
<link href="https://seirdy.one/webmentions/receive" rel="webmention"> <link href="{{ .Site.Params.WebmentionEndpoint }}" rel="webmention">
{{ $webmanifest := resources.Get "/manifest.webmanifest" | resources.ExecuteAsTemplate "manifest.webmanifest" . | resources.Minify | resources.Fingerprint "md5" -}} {{ $webmanifest := resources.Get "/manifest.webmanifest" | resources.ExecuteAsTemplate "manifest.webmanifest" . | resources.Minify | resources.Fingerprint "md5" -}}
{{- printf `<link href="%s" rel="manifest">` $webmanifest.RelPermalink | safeHTML }} {{- printf `<link href="%s" rel="manifest">` $webmanifest.RelPermalink | safeHTML }}
<link rel="alternate" type="application/rss+xml" href="{{ site.BaseURL }}posts/index.xml" title="{{ $.Site.Title }}"> <link rel="alternate" type="application/rss+xml" href="{{ site.BaseURL }}posts/index.xml" title="{{ $.Site.Title }}">
<title>{{ .Title }}{{ if and (lt (len .Title) 54) (ne .RelPermalink "/") }} - Seirdy{{ end }}</title> <title>{{ .Title }}{{ if and (lt (len .Title) 54) (ne $canonicalRelPermalink "/") }} - Seirdy{{ end }}</title>
<meta name="description" content="{{ if .Params.description }}{{ .Params.description }}{{ else }}{{ .Site.Params.Description }}{{ end }}"> <meta name="description" content="{{ if .Params.description }}{{ .Params.description }}{{ else }}{{ .Site.Params.Description }}{{ end }}">
<meta name="author" content="{{ .Site.Author.name }}"> <meta name="author" content="{{ .Site.Author.name }}">
<meta property="article:author" content="{{ .Site.Author.name }}"> <meta property="article:author" content="{{ .Site.Author.name }}">
@ -46,7 +47,7 @@
<style>{{ $css.Content | safeCSS }}</style> <style>{{ $css.Content | safeCSS }}</style>
<meta property="og:title" content="{{ .Title }}"> <meta property="og:title" content="{{ .Title }}">
<meta property="og:site_name" content="{{ $.Site.Title }}"> <meta property="og:site_name" content="{{ $.Site.Title }}">
{{- 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")) }}
<meta property="og:type" content="article"> <meta property="og:type" content="article">
{{- end -}} {{- end -}}
<!-- ANOTHER meta image?! When will it end? --> <!-- ANOTHER meta image?! When will it end? -->
@ -55,7 +56,7 @@
<meta property="og:image:type" content="image/png"> <meta property="og:image:type" content="image/png">
<meta property="og:image:height" content="512"><meta property="og:image:width" content="512"> <meta property="og:image:height" content="512"><meta property="og:image:width" content="512">
<meta property="og:image:alt" content="White-on-black colon and semicolon"> <meta property="og:image:alt" content="White-on-black colon and semicolon">
<meta property="og:url" content="https://seirdy.one{{ .RelPermalink }}"> <meta property="og:url" content="{{ .Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}">
<meta property="og:description" content="{{ if .Params.description }}{{ .Params.description }}{{ else }}{{ .Site.Params.Description }}{{ end }}"> <meta property="og:description" content="{{ if .Params.description }}{{ .Params.description }}{{ else }}{{ .Site.Params.Description }}{{ end }}">
{{ hugo.Generator }} {{ hugo.Generator }}
</head> </head>

View file

@ -1,5 +1,6 @@
{{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" }}
Posted <time itemprop="dateCreated datePublished" class="dt-published published" datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}" title="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Date.Format "2006-01-02" }}</time> Posted <time itemprop="dateCreated datePublished" class="dt-published published" datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}" title="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Date.Format "2006-01-02" }}</time>
by {{- partial "indieweb-author.html" -}} on his <a rel="canonical" itemprop="mainEntityOfPage" class="u-url url" href="https://seirdy.one{{ .RelPermalink }}">Website</a>{{- with .OutputFormats.Get "gemtext" -}}{{- printf " " -}}and <a rel="syndication" class="u-syndication" href="{{replace .Permalink "/gemini" "" 1 | safeURL}}">Gemini capsule</a>{{- end -}}. by {{- partial "indieweb-author.html" -}} on his <a rel="canonical" itemprop="mainEntityOfPage" class="u-url url" href="{{ .Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}">Website</a>{{- with .OutputFormats.Get "gemtext" -}}{{- printf " " -}}and <a rel="syndication" class="u-syndication" href="{{replace .Permalink "/gemini" "" 1 | safeURL}}">Gemini capsule</a>{{- end -}}.
{{ if lt .Date .Lastmod -}} {{ if lt .Date .Lastmod -}}
<br> <br>
Last updated <time itemprop="dateModified" class="dt-updated updated" datetime="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}" title="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Lastmod.Format "2006-01-02" }}</time>. <a href="{{ .Site.Params.logUrlPrefix }}content/{{ .File.Path }}">Changelog</a>. Last updated <time itemprop="dateModified" class="dt-updated updated" datetime="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}" title="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Lastmod.Format "2006-01-02" }}</time>. <a href="{{ .Site.Params.logUrlPrefix }}content/{{ .File.Path }}">Changelog</a>.