Using / for base_url doesn't work properly

using zola server it lets me access all the content of the website, but when using zola build the links don’t work, how can i use base_url without using a url or ip address

basically i want my website to be url agnostic, how is something so easy to do when writting html manually so hard to do on zola?

I think you should be able to do this, as long as you’re not hosting the site on a sub-directory (e.g. example.com/my-site).

Are you using a theme?
And when deploying, what are the actual URLs vs expected URLs?

im not using a theme, just a single css file placed on the static folder

im trying to open the website from my file explorer, but either when using / or ./ as the base url on config.toml, there is something that breaks, here are some examples of my links, both of these work on zola serve but not on zola build

<link rel="stylesheet" href="{{ get_url(path="css/catppuccin_macchiato.css") | safe }}">
<a href="{{ get_url(path='@/blog/_index.md') }}" rel=true>Posts</a>

Your goal is to have the files that are built to be able to be hosted anywhere. I don’t think that will work with how Zola is created.

Unless I’m mistaken, when using functions such as get_url Zola generates the full path to the content. Using a base URL of / won’t work because that will assume the content is the root folder or the website or possibly file system if it’s being open locally. And using ./ doesn’t strike me as a way URLs work these days, but it’s been a long time since I’ve tried that and it. However, the issue is that if you are in a page in a section, home would be ./ which is not true, because you need to go up or back two levels. Same with an empty string.

What you need to do is NOT use get_url because you don’t WANT the url. You need pages to have the relative path.

So if you want to link from ./section1/page1 to ./section2/page2 you need href="../section2/page2" or maybe ../../ to do that. And it’s unique on each page. Hand coded.

But as far as templates, you are out of luck with <link> elements. Because each page would need a different one. In the old days, you would have to specify the relative path by hand, or use a full page, which is not location agnostic. You cannot do this with templates.

If I had to suggest a workaround, it would be to have each section have an extra variable you load in the template with the proper number of ../s to get to the root. Or, pull up what Zola thinks the local path is and trying to calculate how far down the tree you are, and then generating the correct number of ../ to get to the root of your site. Then tack on the rest of the URL from there.

Does anyone have more insight or a better idea?