August 16, 2019

Ghost redirects json

Last week i was reviewing my old blog (, and noticed that all the link that i have there, that is suppose to redirect to my new blog ( wasn't working. The reason is that the link that is put there has the following format


But with the recent update of ghost the url of my blogs changed and hence none of the redirects seem to be working. The change is that they remove year, month, date from the url and started using the blog-title alone as part of the URL. Thanks to google analytics, which helped me analyse and understand the problem. Because of this i lost a bunch of users and page views. Also the users who clicks on these links gets frustrated because they don't have anywhere to go. I decided to fix these links but there were close to 80 of them, which clearly is not an option. I searched for various options from routing in reverse proxy (nginx), any code change to ghost itself , or something like a taiko script to update the source system with proper links. Then i figured out that ghost has this new feature "Redirects" which allow you to configure the source link and destination link declaratively in a JSON format which will then be used by the ghost engine to gracefully serve the blog's. The json also accepts regular expressions for source match and destination substitute. This makes it the ideal choice to go with as i can simply write a regular expression that will trim the year, month, date and return the blog-title alone. Here is how to write it.

[ {
. "permanent":true

Comments powered by Disqus