Skip to content

Commit 22b45b0

Browse files
committed
Allow redirect_to with fully-qualified URLs
So far, we have used the `redirect_to` directive in the front matter only for redirecting to a relative URL. However, in the next commit, we will want to add fall-backs for pages that are not rendered on git-scm.com. This fall-back wants to redirect to the git/git repository and hence does not need `relURL` treatment. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent b12a5d7 commit 22b45b0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

layouts/_default/baseof.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
<!DOCTYPE html>
22
{{ if isset .Params "redirect_to" }}
3+
{{ $redirect_to := .Params.redirect_to }}
4+
{{ if not (hasPrefix $redirect_to "https://") }}
5+
{{ $redirect_to = relURL $redirect_to }}
6+
{{ end }}
37
<html lang="en">
48
<head>
59
<meta charset="utf-8">
610
<title>Redirecting&hellip;</title>
7-
<link rel="canonical" href="{{ relURL .Params.redirect_to }}">
8-
<meta http-equiv="refresh" content="0; url={{ relURL .Params.redirect_to }}">
11+
<link rel="canonical" href="{{ $redirect_to }}">
12+
<meta http-equiv="refresh" content="0; url={{ $redirect_to }}">
913
<meta name="robots" content="noindex">
1014
</head>
1115
<body>
1216
<script>location="{{ relURL .Params.redirect_to }}"</script>
1317
<h1>Redirecting&hellip;</h1>
14-
<a href="{{ relURL .Params.redirect_to }}">Click here if you are not redirected.</a>
18+
<a href="{{ $redirect_to }}">Click here if you are not redirected.</a>
1519
</body>
1620
</html>
1721
{{ else }}

0 commit comments

Comments
 (0)