I saw there were several in the past discussions about configuring URLs without trailing slash.
Is this still not possible in Hugo?
I understand that URL’s without trailing slash is rather a matter of personal preference. I think no trailing slash makes URL simply look better. I don’t see why URL’s must mimic layout on disk. In Jekyll I can configure URL’s without trailing slash:
permalink: /:title
For Jekyll site, in nginx conf, here’s how I configure non-trailing slash and redirect requests to *.html to non-html URL:
Not necessarily. If the URL refers to a directory, the missing slash induces a redirect, thus a second HTTP roundtrip.
Here’s more detail on that:
I never thought of a beauty contest featuring URLs.
There’s no “must” here. It is simply the web server that is working with what it finds on disk. You tell it to look for a file (no trailing slash). The file is not there, but a directory is. So the server sends a redirect with the trailing slash.
(I don’t know how nginx and other servers handle this, though). On Apache, you can perhaps rewrite the URL without a redirect, but that requires mod_proxy to be installed and seems to entail other performance penalties.
The current behavior is technically correct (i.e., request directory, only one roundtrip).
Although we could make it configurable for those who can and want to implement server-side URL rewrites, with near zero demand the cost far outweighs the benefit.
How about allowing no URL on simple files (not directories).
A directory URL can be /dir-name/, but for simple file, I’d like to be able to configure no file extension: /file-name. I just need Hugo to generate file on disk with no extension and use the same file with no extension when generating the URL variables.
Is this possible?
(I’d make the necessary settings in the web server config).