Alexander Zeitler

11ty redirects

Published on Friday, November 22, 2024

Sometimes you want to change urls in 11ty without breaking them.

There are several posts out there explaining how it can be done when your site is running using Netlify, but there's little content how to do it with plain 11ty.

Lucky me, I found this post, which shows a solution by introducing a new 11ty template named eleventy-redirect.njk in the root folder.

In your posts (the ones to which the redirect should point to), add this to your front matter (given your posts are in the articles folder):

---
redirect_from: /articles/my-old-url
---

Make sure to delete the old directory/files from which the direct should happen.

What are your thoughts about
"11ty redirects"?
Drop me a line - I'm looking forward to your feedback!
Please be aware that I'm no longer active on social media. I'm just cross posting things over there (it's a bot).
Imprint | Privacy