Getting pathing to work off file system


I’m trying to work out how to generate a build of my Hugo site that works off the local filesystem, using hugo --baseURL "." but the pathing doesn’t work. Is there a config option to force absolute pathing to the root for all pages and resources?


What you want is relativeURLs=true, but it requires dicipline in the URL department.


Okay, thanks, here goes…


No luck. I set relativeURLs=true in the config.toml (because I don’t seem to be able to use it with the cli) and used hugo --baseURL "." --uglyURLs. The path to my CSS files is still not truly relative (rewritten with ../../ etc for nested folders). Is part of the problem that I’m using absURL for my CSS pathing ({{ "css/styles.css" | absURL }})?


Yes, you can not use absolute URLs, which was part of my “URL dicipline” remark above.

You can set config vars via env vars …


or something.


Sorry, I’m not sure what you mean by discipline. If I use relURL should I expect the value to be modified automatically when HUGO_RELATIVEURLS=true is set?

hugo --baseURL "." HUGO_RELATIVEURLS=true

Is that the right command?


Hugo has no way of guessing what to do with absolute URLs. So to use relativeURLs=true you have to use relURL or similar. And your command is not the same as in my example above.

I can not help you further on this. This may be an “expert feature” that requires one to understand some of the internals of Hugo, I guess. We may improve on that in the future.


Thanks, that’s working now aside from the tag folders which aren’t respecting uglyURLs. It’ll do. Nice one!