We use Hugo v0.30.2 to generate online documenation for base URL www.company.com/docs/
where www.company.com
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/targetpage.md content file:
aliases:
- "/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, www.company/docs/xxx/sourcepage/
is redirected to www.company/xxx/targetpage/
instead of to www.company/docs/xxx/targetpage/
— 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
.