Getting pathing to work off file system


#1

Hey,
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?


#2

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


#3

Okay, thanks, here goes…


#4

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 }})?


#5

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

You can set config vars via env vars …

HUGO_RELATIVEURLS=true hugo

or something.


#6

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?


#7

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.


#8

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