How to create a redirect for your Ghost blog

It is not exactly intuitive how to make redirects on your Ghost blog if you are less tech savvy, however it is very easy! There is no user interface where you can put in the URLs you wish to redirect from and to, you have to edit and upload a json file to do so.

How to make redirects on your ghost blog

First step is to download your current list of redirects. You do this by going to the labs section of your back office and scroll to the bottom (yes I use dark mode):

Ghost-blog-redirect-file-location

Here you will be able to do two things: download your current redirects.json file and upload a new one. To add a redirect you need to download the redirect file, which will look something like the following when you open it:

 []

Which is an empty json array, here you need to fill in your redirects. Below is an example on how I redirect from one URL to another - because I changed a typo in the URL where I replaced the word class with struct:

 [{
     "from": "/2020/05/16/c-how-to-mock-or-stub-the-datetime-class-for-tests/",
     "to": "/2020/05/16/c-how-to-mock-or-stub-the-datetime-struct-for-tests/",
     "permanent": true
 }]

The above is straight forward, write in the URL path you want to redirect from in the "from" part and where it should redirect to, in the "to" part. The "permanent" field dictates if it should be a permanent or temporary redirect. In short you should make it false if the from URL is only temporarily unavailable and not permanently replaced.

When you have added your redirects upload the redirects.json file using the "upload redirects file" button as shown in the image above.

In order to add more than one redirect, add more redirect objects to the list, remember to add a comma between them. Here is an example:

[
 {
     "from": "/2020/05/16/c-how-to-mock-or-stub-the-datetime-class-for-tests/",
     "to": "/2020/05/16/c-how-to-mock-or-stub-the-datetime-struct-for-tests/",
     "permanent": true
 },
 {
     "from": "/2020/02/18/some-url-to-redirect-from/",
     "to": "/2020/02/18/some-url-to-redirect-to/",
     "permanent": true
 }
]

You can also redirect to other domains, but remember to include the protocol (HTTPS/HTTP):

[
 {
   "from": "/test-redirect-to-google",
   "to": "https://www.google.com",
   "permanent": false
 }
]  

That is it

You have now created a redirect between two pages on your blog :) Let me know in the comments if this helped you!