Netlify, Gatsby and trailing slashes

I guess it happens.

I was collecting some insights, and I found this pretty annoying bug in the network debug panel: my paths have no trailing slashes, but, Netlify automatically redirects to URLs with trailing slashes with a 301 redirect.

To fix that, you can either turn it off on Netlify’s interface (which is one the greatest I’ve ever seen, by the way), or, and I prefer this way, add a simple rule in the netlify.toml file of the project:

[build.processing.html]
  pretty_urls = false

Put this file at the root of your project (if you use Netlify, of course), and that’s it.

Because of React, it’s not necessary to use the “pretty urls” option.

Fortunately, I always have a canonical meta, but that was a nasty surprise.

In case you want to know more, here is an interesting thread about it

I also found a piece of explanation here.