Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added redirect capability; see redirects.md for more… #194

Merged
merged 2 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions _includes/redirect.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0; url='{{ redirect.to }}'" />
<style>
html, body {height: 90%; width: 99%;}
body {display: flex; align-items: center; justify-content: center; font-size: 2vmax;}
</style>
</head>
<body>
<p>If you can see this, you should be redirecting this URL to <a href="{{ redirect.to }}">{{ redirect.to }}</a>.</p>
</body>
</html>
28 changes: 28 additions & 0 deletions redirects.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
# SOURCE: https://github.com/11ty/eleventy/issues/510#issuecomment-824104799
# See also: _includes/redirect.njk
#
# This file does hijinx with the "pagingation" system to generate many small pages from one set of data...
# and uses that do to redirects from some URLs to others.
# We use this to try to keep old links working.
#
# There's limited power to this approach (it only works for specific pages listed; it can't glob),
# but those are limitations inherent to an approach that works via static site gen, rather than via server configuration.
# The related upside of an approach that works via static site gen is the portability.
pagination:
data: redirects
size: 1
alias: redirect

# Add your redirection tuples to this list!
redirects:
- {"from": "/about/get-started.html", "to": "/about/get-wpe.html"}
- {"from": "/about/explore-wpe.html", "to": "/about/get-wpe.html"}
- {"from": "/code/", "to": "/about/get-wpe.html"}

# The "permalink" attribute determines where the output page will be located.
permalink: "{{ redirect.from }}"

# The "redirect" layout just has a small html header with the meta tags that do redirection.
layout: redirect
---