Alias redirect issues with a "sub-domain" base URL


We use Hugo v0.30.2 to generate online documenation for base URL where is the URL of the company’s WordPress site. This works, but I’ve now encountered a problem:

I added the following alias definition in an xxx/ content file:

  - "/xxx/sourcepage/"

On the local server, http://localhost:1313/xxx/sourcepage/ is succesfully redirected to http://localhost:1313/xxx/targetpage/. But on the company site, is redirected to instead of to — i.e., docs/ is missing from the path, which results in a Page Not Found error.

I see that Hugo created an xxx/sourcepage/index.html file that has an HTML <head> element with <link rel="canonical" href="/xxx/targetpage/"/> and <meta http-equiv="refresh" content="0; url="/xxx/targetpage/" /> elements. If I manually edit the URL paths in these elements to ../xxx/targetpage/, the redirect succeeds.

We set baseURL in config.toml to "" and then set it dynamically using Gulp and JavaScript. We also set canonifyURLs and relativeURLS to true, and uglyurls to false.


This is by design. The aliases are used as they are. There is no (easy) way we can guess what you mean.


But I’m not asking Hugo to guess. My assumption, based also on the examples in the Hugo documentation, is that an alias that begins with / is relative to the configured base URL. So, for example, an /xxx/ alias would redirect http://localhost:1313/xxx/ when using the local server, but would redirect for a site built with base URL Isn’t this the case?


No, your assumption is wrong.There is no logic in the alias parsing, as that would break pretty fast.

Also, even if you think this should have behaved differently, we cannot change it.


Are the following alias values expected to work?

  1. A relative URL such as ../../xxx/.
  2. An abosolute URL such as