Config option for disabling trailing slashes

We’re using Zola to generate a site with a URL structure that does not include trailing slashes. Our server software automatically redirects to strip the trailing slashes. Since URLs with Zola are generated with trailing slashes right now, I’m seeing two issues:

  1. Social media buttons on our site don’t work perfectly. In particular, if you click on our Reddit share link, the “already posted” search will fail, since the page with and without the slash do not match.
  2. All link clicks result in an extra roundtrip for the intermediate 301.

I wrote a simple patch to allow a trailing_slash config value:

This seems to solve the problem for us, and I’d be interested in sending a PR to add it. Opening here for discussion of the feature and to see if it would be acceptable for the project.

Thanks for all the work on Zola, it’s much appreciated!

2 Likes