Static site generator Hugo doesn’t allow URLs without trailing slashes

 
1 Kudos
Don't
move!

I checked out Hugo – a fast static site generator. Why use a static site generator? Because why would the server have to rebuild the page for every visitor instead of building it once? Especially, if content doesn’t change often. A static site generator compiles the website once and it’s served much faster to visitors.

Anyways, while Hugo seems like a great product, there’s one downside:

As of beginning of 2017, there is no support for removing trailing slashes from URLs, because every page generated by Hugo is a folder with an index.html. No mod_rewrite or anything.

The advantage is: Hugo-generated websites run on every webserver without hacks or additional configuration requirements.

But if you want to move your website from a CMS to a static Hugo-generated website and retain your current URL scheme, it won’t work out of the box.

The question now is: Why would you want to keep your exact URL scheme? Because sometimes, things might break if you don’t. Maybe local anchor links such as these might break – or not.

www.example.com/test#example
www.example.com/test/#example

I use Piwik for web analytics and Piwik shows URLs with trailing slashes in a different way than URLs without a trailing slash. This even results in pages being counted as separate pages if a user visits example.com/test/ or example.com/test.

Before you decide to use Hugo, think about whether or not control over trailing slashes are important to you or not.

Source: https://discuss.gohugo.io/t/links-without-a-trailing-slash/831

Leave a Reply

Your email address will not be published. Required fields are marked *