If you use Hugo, we’ve all been there: create a post, give it a url - spell something wrong in the url, doh! This post hopes to explain how you can change the URL of a post, while preserving the SEO benefits associated with it.
We can do this, by changing the URL on the post to what we want then setting up an alias for the old url. This was existing traffic and Google still know what’s going on and will treat it as the same page.
1. Change Post URL
from incorrect url: url: /how-to-chaneg-url-on-post/
to fixed url: url: /how-to-change-url-on-post/
2. Create an Alias
title:"How to Change a URL"type:posturl:/how-to-change-url-on-post/aliases:['/how-to-chaneg-url-on-post/']
In the example above, we used the ‘aliases’ section to create a dummy page for us. This page just contains a redirect link to our new page using a meta tag.
Add a 404 Not Found Page
In an ideal world, every web page would exist, but sometimes links go to pages that doen’t exist. This is why we make “404 - not found” pages. In Hugo you can do the same. Many of our sites are hosted with Netlify which also support these files - automatically returning the correct http status code for them.
To make yours, you can add a file into your layouts folder.
Hide a Page in Hugo
Option 1: Draft The simplest way to hide a page when using Hugo is probably to set the post as a draft. This way, you still have the content ready to go for when you need it.
To hide a page by setting it as draft, so our drafts page:
Set Post as Draft Tutorial Option 2: Hide from Posts List You still want the page to be visible, but you don’t want to show it your blog posts list?
Make a Static Page in Hugo