Leaving base_url empty

Hi! I might be missing something but why doesn’t Zola let me assign base_url to a value of an empty string. There’s no need for the relative or absolute links to contain the domain name, the browser adds them automatically. If I click <a href="/archive">Archive</a> link on website myblog.com the browser automatically sends me to myblog.com/archive.

Currently Zola hardcodes all links with the full domain (mywebsiteurl.com/path instead of /path). This makes testing a lot harder, and you can’t access the website with IP address (important mostly when testing, or when the domain stops working etc). I can’t see a single good reason for this. base_url = “/” doesn’t work either because then links start with “//myurl”

Should I create a Github issue or is there something I’m missing? Thanks!

3 Likes

There’s no way to have an empty base_url no, that’s intentional.

What do you mean it’s harder? You need to use zola serve for local testing

I just can’t see the reason for hardcoding the domain name to website links. I’d like to serve my site on my web server and keep a mirror on Github Pages. And I’d like to test the deployment on my web server before getting a domain name. Now every situation needs a custom build script or Github pipeline when zero would be enough. I can’t see any upsides to hardcoding URL:s like that.

Is there a reason for disabling empty base_url that I’m missing?

1 Like

Sitemap and feeds do require an absolute URL.

1 Like

For me this is a very important issue and maybe a deal breaker for using zola.

Some very concrete usecases:

  • Publishing on IPFS where a user may use any arbitrary URL that happens to have an IPFS node running.
  • Serve my site on my web server and keep a mirror on Github Pages
  • Access my site via IP address when DNS hasn’t updated or is otherwise slow, broken, or inconvenient
  • Host my site at my main URL, but also at my legacy URL that some people might still have bookmarked

The counterpoint that “Sitemap and feeds do require an absolute URL” also has validity, but this is no reason to still hardcode the base URL in stylesheet links and etc. Some sites don’t even use feeds, and while sitemaps are nice, I would argue they are secondary to the site itself and could perhaps be optional if no canonical base_url is provided.

1 Like