From ba5040453a7422f162627f8755e180d81feaaff5 Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Sat, 7 Nov 2020 23:07:19 -0500 Subject: [PATCH] New post --- content/blog/personalsitepreservingurls.md | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 content/blog/personalsitepreservingurls.md diff --git a/content/blog/personalsitepreservingurls.md b/content/blog/personalsitepreservingurls.md new file mode 100644 index 0000000..2620c17 --- /dev/null +++ b/content/blog/personalsitepreservingurls.md @@ -0,0 +1,41 @@ +--- +title: "Preserving Classic URLs on my Website" +date: 2020-10-28T21:06:57-04:00 +draft: false +tags: [] +--- + +At some point in 2018 I switched my website from using Wordpress on the backend to Hugo. I used a simple script to migrate everything over and in that migration a few things broke. + +- Code snippets do not show up +- Images don't show up +- URLs are different + +I've gone back through some of my old posts and fixed up the code snippets. I usually decide to go back when I see sufficient traffic to one of those older pages. + +I recently discovered that Hugo supported [aliases](https://gohugo.io/content-management/urls/#aliases). This will allow me to setup redirect at the old URLs that my blog posts used to be in. I can do this by adding a small snippet to my front YAML. + +```yaml +aliases: + - /2018/06/05/old/url/here +``` + +This will then redirect `https://brandonrozek.com/2018/06/05/old/url/here` to the current URL of the post I'm editing. + +When I discovered this, I went ahead and redirected all my old URL blog posts to their current day versions. It makes me happy that I'm lowering the amount of link rot that I'm contributing to the web. + +How does it do this? It creates a simple webpage that contains a HTTP-Equiv tag which tells the browser to redirect it. Directly from the Hugo documentation: + +```html + + + + https://example.com/posts/my-intended-url + + + + + + +``` +