theme: make alias pages usable by file:// protocol #398

This commit is contained in:
Sören Weber 2022-11-19 16:05:59 +01:00
parent 573fd99482
commit 99fe90f9b2
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
2 changed files with 20 additions and 2 deletions

14
layouts/alias.html Normal file
View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="{{ site.LanguageCode | default site.Language.Lang | default "en" }}" dir="{{ T "Reading-direction" | default "ltr" }}">
<head>
{{- $url := replace (replace .Permalink site.BaseURL "/") "//" "/" }}
{{- $url = partial "relLangPrettyUglyURL.hugo" (dict "link" $url) }}
<meta charset="utf-8">
<meta name="robots" content="noindex">
<meta http-equiv="refresh" content="0; url={{ $url }}">
{{- $link := "<link href=\"%s\" rel=\"%s\" type=\"%s\" title=\"%s\">" }}
<title>{{ $url }}</title>
{{ (printf $link $url "canonical" "text/html" ($url | htmlEscape)) | safeHTML }}
</head>
</html>

View file

@ -1,9 +1,13 @@
{{- $to := .to }} {{- $to := .to }}
{{- $abs := .abs }} {{- $abs := .abs }}
{{- $basename := .basename }} {{- $basename := .basename }}
{{- $link := $to.RelPermalink }} {{- $link := "" }}
{{- if $abs }} {{- if isset . "link" }}
{{- $link = .link }}
{{- else if $abs }}
{{- $link = $to.Permalink }} {{- $link = $to.Permalink }}
{{- else }}
{{- $link = $to.RelPermalink }}
{{- end }} {{- end }}
{{- if not $basename }} {{- if not $basename }}
{{- $basename = "index" }} {{- $basename = "index" }}