From 99fe90f9b2e45dea56c6bc0c19783a7978f4e805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sat, 19 Nov 2022 16:05:59 +0100 Subject: [PATCH] theme: make alias pages usable by file:// protocol #398 --- layouts/alias.html | 14 ++++++++++++++ layouts/partials/relLangPrettyUglyURL.hugo | 8 ++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 layouts/alias.html diff --git a/layouts/alias.html b/layouts/alias.html new file mode 100644 index 0000000000..190f81fa82 --- /dev/null +++ b/layouts/alias.html @@ -0,0 +1,14 @@ + + + + {{- $url := replace (replace .Permalink site.BaseURL "/") "//" "/" }} + {{- $url = partial "relLangPrettyUglyURL.hugo" (dict "link" $url) }} + + + + {{- $link := "" }} + {{ $url }} + + {{ (printf $link $url "canonical" "text/html" ($url | htmlEscape)) | safeHTML }} + + diff --git a/layouts/partials/relLangPrettyUglyURL.hugo b/layouts/partials/relLangPrettyUglyURL.hugo index 1d711c7fd9..c0ab2a6b41 100644 --- a/layouts/partials/relLangPrettyUglyURL.hugo +++ b/layouts/partials/relLangPrettyUglyURL.hugo @@ -1,9 +1,13 @@ {{- $to := .to }} {{- $abs := .abs }} {{- $basename := .basename }} -{{- $link := $to.RelPermalink }} -{{- if $abs }} +{{- $link := "" }} +{{- if isset . "link" }} + {{- $link = .link }} +{{- else if $abs }} {{- $link = $to.Permalink }} +{{- else }} + {{- $link = $to.RelPermalink }} {{- end }} {{- if not $basename }} {{- $basename = "index" }}