Perfection impedes achievement

Mixed case URLs in Hugo

· by Paul Klink · Read in about 2 min · (294 Words)

Should URLs contain both upper and lower case characters? A quick search on the internet suggests that the answer is a resounding «no». Only use lowercase characters! While using a mixture of upper and lower case will make URLs more readable, it has the following disadvantages:

  1. If your webserver ignores character case in URLs (eg. IIS), then links to your web pages can use URLs with different case characters. These links will break if you move your website to a different server which does not ignore character case in URLs.

  2. Search engines may consider that URLs with different case characters represent different resources.

  3. Search engines give a lower ranking to URLs which are not all lower case.

Items (1) & (2) above are probably not particularly relevant since my website is hosted on a URL case sensitive server. In terms of ranking, mixing upper & lower case in URLs no longer seems to matter.

The thing is, I like mixed case in my URLs so much better. I like it that they are more readable. This may even be beneficial with search engines. As John Sherrod mentions, by including capital letters, you provide additional information in URLs which search engines can use to work out your intent.

Anyway, so how does this apply to Hugo…

By default, Hugo converts all folders and files under your «content» directory to lower case when generating URLs. However there are some anomalies (bugs) in this transformation. For example, I had a lot of problems referencing files when the section names consisted of upper and lower case characters.

If you want to use upper and lower case characters in your paths, set the following variable in your config file:

disablePathToLower = true 

Things will work a lot better.