ElBlo
Relative URLs in hugo serve
By default, using hugo serve
with a custom port will emit absolute URLs.
In the weird case in which you want hugo
to be using relative URLs, you need to do some tweaks:
- Set
--apendPort
tofalse
. - Set
--baseURL
to"/"
.
For example:
$ hugo serve --buildDrafts --port "${PORT}" --appendPort=false --baseURL="/"
By default appendPort
is true
, which will append the port to all your site URLs, forcing absolute URLs everywhere.
And, as an IDX preview:
idx.previews = {
enable = true;
previews = [
{
command = [
"hugo"
"serve"
"--buildDrafts"
"--source" "/home/user/develop/www"
"--port" "$PORT"
"--appendPort=false"
"--baseURL" "/"
];
manager = "web";
id = "web";
}
];
};
Sadly, Hugo’s liveReload doesn’t work with IDX yet 😔.