Don't change your site routes, like me

How do I have a lot of 404 errors that cause changes in the route to my posts and how do I fix it!

Don't change your site routes, like me
Photo by José Martín Ramírez Carrasco / Unsplash

I switched my blog front, previously Sveltekit, now using full Ghost. Ghost Front has a lot of features that I like but got no time to put this in my project.
There is one week since the new version is in production (or close to that) and I forget something important: The routes.

The new routes for a post are just the base URL (tuliocalil.com.br) and the post slug. The old one was a /post/ between the base URL and post slug.

Old -> https://www.tuliocalil.com.br/post/criando-servico-de-envio-de-e-mail-com-elixir
New -> https://www.tuliocalil.com.br/criando-servico-de-envio-de-e-mail-com-elixir

Google Search Console send me an alert about a 404 error on some of my links in sitemap.xml. When I see and process all I think: Ops, maybe I lost some views 😅.

Getting to Google Analytics and check the access routes for the last week to see how many impacted users:

Ok, let's go fix that!
Happily, Ghost has a route redirect system easy to use, we just upload a YAML or JSON file with de rules and we did. Regex is supported too, and the mine looks like this:

301:
  ^\/post\/([a-z0-9-]+)\/$: /$1

Now if someone open my old links will be redirected to the new URL.
To finish the fix, I just replaced my sitemap.xml from Google Search Console and we did!