I’m using so-called “ugly URLs” in Hugo to generate nice standard pages, with e.g. about.html, contact.html, and info.html pages. This gives me a clean, uncluttered file layout which is easy to navigate (no hundreds of folders just to contain different index.html files).
On the web server, I’m using URL rewriting to create my pretty URLs. For example, a web request for “/about” gets rewritten to “/about.html”, and the content gets served up correctly.
This all works fine, and I don’t think it’s anything out of the ordinary.
However, I want my Hugo content to be compatible with this URL rewriting setup. If I use something like {{ ref . "about.md" }}
to link to a file, I want Hugo to output a URL compatible with the server’s URL rewriting, i.e. “/about” instead of “/about.html”.
I suppose essentially what I’m asking for is to have files generated according to uglyURLs=true
, but URLs to be generated according to uglyURLs=false
. Or alternatively, some way to specify the URL for pages but without changing the file that they get compiled to. I thought of the “url” front matter variable, but that actually seems to change the output file, which isn’t what I want.
Is there any way to do this? I’ve searched and haven’t found anything, which seems odd to me as I believe URL rewriting is very common. The only solution I can think of is to manually specify all URLs, which would work but would not be very maintainable when a lot of links are involved.
Any ideas? Thanks.