Skip to content

feature: add redirect from old blog post location #1209

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

Merged
merged 1 commit into from
Jul 12, 2024
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
2 changes: 2 additions & 0 deletions src/posts/first-post.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ draft: false
description: Creating a blog!
tags:
- intro
redirect_from:
- /blog/first-post
---

I have been building a [homelab](https://www.reddit.com/r/homelab/wiki/introduction) for the last few years, mostly to [self-host](https://www.reddit.com/r/selfhosted/) services securely at home without relying on the major cloud providers. I've learned a lot going through the experience and wanted to start sharing some of the knowledge back to the community outside of a few tiny pull requests that I've made. Look for more coming soon!
2 changes: 2 additions & 0 deletions src/posts/moar-fediverse.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ tags:
- fediverse
- homelab
- selfhosted
redirect_from:
- /blog/moar-fediverse
---

I've been running a single user Mastodon instance for a few months now. It's been running smoothly and has let me interact with the exodus of users from the bird site. But it can be lonely on a single user instance. Discovery can be hard, following #hashtags only shows you posts from
Expand Down
2 changes: 2 additions & 0 deletions src/posts/tailscale-hostnames-for-pi-hole-stats.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ tags:
- tailscale
- pi-hole
- magicdns
redirect_from:
- /blog/tailscale-hostnames-for-pi-hole-stats
---
[Tailscale](https://tailscale.com) is a fantastic secure mesh VPN that lets you connect all of your devices to each other, no matter where they are or if you've exposed them publicly to the internet. I use it extensively to use all my homelab services and run it on virtually every server. They have a very generous free tier and hope that enthusiasts enjoy it so much that they bring it to their workplace.

Expand Down
37 changes: 37 additions & 0 deletions src/redirect.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---js
{
pagination: {
data: "collections.all",
size: 1,
alias: "redirect",
before: function (data) {
return data.reduce((redirects, page) => {
if (Array.isArray(page.data.redirect_from)) {
for (let url of page.data.redirect_from) {
redirects.push({ to: page.url, from: url });
}
} else if (typeof page.data.redirect_from === 'string') {
redirects.push({ to: page.url, from: page.data.redirect_from });
}
return redirects;
}, []);
},
addAllPagesToCollections: false,
},
permalink: "{{ redirect.from }}/index.html",
eleventyExcludeFromCollections: true,
}
---
<!DOCTYPE html>
<html lang="en-US">
<meta charset="utf-8" />
<title>Redirecting&hellip;</title>
<link rel="canonical" href="{{ redirect.to | url }}" />
<script>
location = '{{ redirect.to | url }}';
</script>
<meta http-equiv="refresh" content="0; url={{ redirect.to | url }}" />
<meta name="robots" content="noindex" />
<h1>Redirecting&hellip;</h1>
<a href="{{ redirect.to | url }}">Click here if you are not redirected.</a>
</html>