Config option for trailing slashes

I notice back in 2017 the original behaviour of Zola was altered from:

  1. Not appending a trailing to slash (https://www.example.com/about), to
  2. Always appending a trailing slash (https://www.example.com/about/).

The reason given was that for many (but not all…) web servers this would result in an unnecessary redirect.

Further, I noticed that shortly after, an option was added to get_url to remove trailing slashes due to conflicts that were arising with linking to assets.

As many websites prefer to operate with pretty URLs that omit the trailing slash (and are willing to do the web server url rewrite to achieve it) it would be great if we could opt-out of the trailing slash behaviour at a global level.

For backwards compatibility the default would of course be trailing_slashes = true, but if trailing_slashes = false the original ‘non-trailing slash’ behaviour would prevail. Then, get_url could also adopt the setting in the config as its default – with override possible via the trailing_slash option, as today.

Thanks for considering!

This was also mentioned by another user: Config option for disabling trailing slashes