Aliases not working

I have


I am using in the front matter of both content files:

aliases = [
aliases = [


When I generate the site and go to localhost:1313/drug1 or localhost:1313/drug2, I get a 404

How come the alias won’t work?

I want the page to be accessible by going to

or takes you to

It works when I build the site on server. When I test locally, I don’t get this behavior as I expect.

Shall I use Permalinks settings? drugs = /:section/:slug? But I think that only affects that particular section

Repo is public:

It should work.

It’s hard to guess whad exactly is going wrong without seeing the whole site code, though. Consider sharing the repository.

I was making it public and it is now in the original post.

I switched to hugo serve and it’s working now! What is happening?!

When I use

hugo --ignoreCache --disableFastRender I get some issues sometimes.

Also, a few pages are still not showing up. is OK

but is 404

Works for me with hugo server.

You need to do something about lettercase of your aliases, though. /1B-LSD redirects to /drugs/1b-lsd (as you have written) :wink:

Yes, I was just about to ask about that.

How can I prevent slug from being lowercased or … I don’t know how hugo handles it.

What if I wanted the pages to be accessible at both lower case and uppercase? does exist, doesn’t it?

Computers never do what you want them to do. They do what you ask them to do.

It does when you go to /drugs/25t-4-nbome

It seems they only work when going to the lowercase version of the name.

How can I have hugo also work it with uppercase? As in don’t modify the title to be slug lowercase? I don’t know.

If I go here to lowercase, that doesn’t show up either. But it does in /drugs/

There is a disablePathToLower option in config. Documented, too.

That seems like a global setting and not a per section setting.

Yes, it is a global one.

As far as I know, your best bet is to have two aliases for each drug page: ["/dRuGNaME", "/drugs/dRuGNaME"] should work really nicely.

I mean, trouble is, people could type in or 1P-lsd or 1P-LSD or 1P-lsd and I want them all to go to /drugs/1p-lsd

Is my only option nginx redirects?

Definitely not the only one: you can use apache redirects, too…

I don’t use Apache. I’m an Nginx guy. Should have said httpd redirects. :slight_smile:

Basically, yes, it you want real case-insensitivity, your best bet is handling it in the server. Which actually makes sense if you think hard of it: URLs are case-sensitive by design, and Hugo does what it is supposed to do here. Making it work from Hugo would require creating aliases for all the possible mixed-case scenarios for each page. It’s simply too much hassle for what can be done with a single line in server config.

Ok. I think I’m going to take off the aliases on these pages altogether. I have another section called /psychedelics/ where say /dmt/ is supposed to go, and that gives issues. Plus, it’s better for organization to leave them in /drugs. Or maybe eventually merge them in /psychedelics.

I have to think about this.

Thank you.


In case anyone cares:

1: install nginx http lua module

location ~ /drugs/[A-Z] {
    rewrite_by_lua 'ngx.exec(string.lower(ngx.var.uri))';