How to configure 301 redirect in Ghost CMS?

How to configure 301 redirect in Ghost CMS?

When you start writing blogs on the Ghost CMS, you won't recognize that the URL for your blog gets picked up when you write the title for the first time, i.e. when you updated the title then the URL is not updated. This is a huge problem, why? A lot of times we are not sure of the title before we start writing blogs hence we might end up putting a placeholder title, once the blog is over, we would update the title, but forget to update the URL. Hence we would see a bad URL for our blog.

Ghost allows you to update the URL, but here is a major problem, if you have updated the URL after a couple of days and google bot has already indexed your page, every time a user clicks on the page they would hit the old URL and finally get a 404 page. That is a bad user experience, which you would want to avoid. So what is the solution for this?

Ghost admin has a Redirects feature that can help you upload a YAML/JSON file to configure any 301 redirects. Ghost CMS is notorious to keep most of the custom features hidden, it took me quite some time to find out the redirection feature which can help you perform any 301 HTTP permanent redirect or even 302 HTTP  temporary redirect.

Go to Settings and then select the Labs section.

Ghost admin settings -> labs

Until now I have had only one such experience where I had a bad URL, so this is the URL redirect config I had to upload. As understood from the configuration, the from URL is used for the old URL which you want to redirect to the new to URL.

[
  {
    "from": "/how-to-create-custom-signal-and-receiver-in/",
    "to": "/how-to-add-custom-signals-dispatch-in-django/",
    "permanent": true
  }
]
PS- Try to reverify all your URLs before you publish the content or even after you have published your content in order to have a better user experience.