forked from austinjavascript/austinjavascript.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
redirects.liquid
38 lines (34 loc) · 1.6 KB
/
redirects.liquid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
---
pagination:
data: redirects
size: 1
alias: redirect
permalink: "{{ redirect.permalink.old }}"
---
{#
This is the closest we can get to 301 redirects in GitHub Pages.
This template uses meta refresh to redirect from the old path to the new permalink in 0 seconds
(change that delay if you wish the page to appear for longer, though if you do, note that the
template is basic and un-styled). The template also sets the canonical link to the
new page location and a link in the body, in case the browser doesn't do meta refresh.
This template uses 11ty Pagination to create pages with data (https://www.11ty.dev/docs/pages-from-data/)
from `_data/redirects.json`. Note that there is additional old/new file mapping in
that file that may be removed if it's not needed.
The obvious downside to this approach is that files are created in the root or posts
directory for each of the old permalinks. At worst, this may result in namespace collisions
should a future filename/permalink match one of the redirect permalinks. Otherwise,
this approach merely clutters up the output directory with "old" files.
We may want to sunset this approach as traffic to the old pages drops off to a certain level.
#}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0;url={{ redirect.permalink.new | url }}" />
<link rel="canonical" href="{{ redirect.permalink.new | url }}" />
</head>
<body>
<h1>Redirecting</h1>
<p>This page been moved to <a href="{{ redirect.permalink.new | url }}">{{ redirect.permalink.new | url }}</a>.</p>
</body>
</html>