A bit ago I realized I needed to generate redirect text for each of my current blog posts. Before posting about that; however, I wanted to go over redirects briefly... that said, if you are looking for the full solution now you can find the original post on my website at Oh No, I Need to Create Redirect Text for All My Posts!. Both there and below will be talk about the redirect file through the Ghost interface.
A redirect is when you want to send someone to a different URL than the one they just typed in. For me I wanted to do this back when I first migrated from Wordpress to Ghost and again when I changed all of my posts' urls to better organize my site. This meant that all of my currently set links no longer worked as they now pointed to the old location with a 404 Page not found
error and I needed to redirect them to the new location.
To do this redirect, through Ghost, you need to find the redirect file by going to your domain and then typing in /ghost/#/settings/labs
immediately afterwards. In my current website, running version 5.82.3+moya this looks like:
While my localhost instance, which is still running version 5.39.0, it instead is a two step process that starts with the labs, in the lower right corner:
And then shows the sub-options here:
The redirect file itself is essentially just an array []
where each object is a single redirect consisting of the from, to, and whether it's permanent or not. So, in my case, if my old blog posts' urls were domain/2017/10/16/halloween-costume-chuggington-onesie/
and domain/2017/11/25/make-your-own-playdough/
the their new ones would now be domain/halloween-costume-chuggington-onesie/
and domain/make-your-own-playdough/
In this example the array would look something like this:
[{"from":"/2017/10/16/halloween-costume-chuggington-onesie/","to":"/halloween-costume-chuggington-onesie/","permanent":true},
{another redirect objects},
...
{another redirect},
{"from":"/2017/11/25/make-your-own-playdough/","to":"/make-your-own-playdough/","permanent":true}]
Once you download and edit the file you can upload it back to your website through the same page. If there's an error it will tell you immediately and, worse case, you can use an online json
editor to help find your issue. Once it's uploaded properly you can then type in the old link and you'll be redirected to the new one rather than get the old pesky 404 Page not found
error again.
Word of warning: Just be sure this file was entered correctly. You don't want to redirect a working page url to a non-working one. I did that with my about page by mistake and ended up just editing its url for a quick solution rather than figuring how to undo the redirect.
And with that I'll leave you with some links in case your want more information about Ghost's documentation on redirects or their tutorial about Implementing redirects. Hope you're having a great day!
Top comments (0)