Skip to content

Commit 99fe90f

Browse files
committed
theme: make alias pages usable by file:// protocol matcornic#398
1 parent 573fd99 commit 99fe90f

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

layouts/alias.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="{{ site.LanguageCode | default site.Language.Lang | default "en" }}" dir="{{ T "Reading-direction" | default "ltr" }}">
3+
<head>
4+
{{- $url := replace (replace .Permalink site.BaseURL "/") "//" "/" }}
5+
{{- $url = partial "relLangPrettyUglyURL.hugo" (dict "link" $url) }}
6+
<meta charset="utf-8">
7+
<meta name="robots" content="noindex">
8+
<meta http-equiv="refresh" content="0; url={{ $url }}">
9+
{{- $link := "<link href=\"%s\" rel=\"%s\" type=\"%s\" title=\"%s\">" }}
10+
<title>{{ $url }}</title>
11+
12+
{{ (printf $link $url "canonical" "text/html" ($url | htmlEscape)) | safeHTML }}
13+
</head>
14+
</html>

layouts/partials/relLangPrettyUglyURL.hugo

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
{{- $to := .to }}
22
{{- $abs := .abs }}
33
{{- $basename := .basename }}
4-
{{- $link := $to.RelPermalink }}
5-
{{- if $abs }}
4+
{{- $link := "" }}
5+
{{- if isset . "link" }}
6+
{{- $link = .link }}
7+
{{- else if $abs }}
68
{{- $link = $to.Permalink }}
9+
{{- else }}
10+
{{- $link = $to.RelPermalink }}
711
{{- end }}
812
{{- if not $basename }}
913
{{- $basename = "index" }}

0 commit comments

Comments
 (0)