I cannot know in advance what the BaseUrl will be.
I know urlpath on which blog will be hosted, for example /blog
I use i18n, so for example I have 2 html that located in /blog/en/index.html and /blog/fr/index.html
Static files are shared between en in fr versions, and for example have path like this /blog/css/style.css
How I should define link to css or images in index.html, so the final url in index.html to css will looks like this ../css/style.css or like this /blog/css/style.css
I tried to do the next things:
define in config file baseURL: "/blog"
define url in this way {{.Site.BaseURL}}/css/styles.css final url will be equal /blog/css/styles.css/
But when I try to start hugo server it generate url like this Web Server is available at //localhost:1313///blog/ (bind address 127.0.0.1)
And this url does not work.
I’m trying to imagine why this is. Is it the case you are handing a rendered site over to someone?
I mean, say I have an idea for a site before the domain, I just start developing, and if I put it online I use a staging URL, but when I get ready to host I will set the baseURL as needed.
Now, if I were distributing a package of HTML (though probably not /blog), I’d create templates that didn’t reference the baseURL. But that means tracking down each instance of how it is referenced and ensuring the paths do what you want.
I know that last paragraph sounds obvious, but I want to point out that all the URLs pointing to resources in the head are created by the templates, not the configuration exactly. Remove {{.SiteBaseURL}} from the template, since you don’t know what that is.
I’m trying to imagine why this is. Is it the case you are handing a rendered site over to someone?
More like, build/render site once and then upload result to different host/domains.
Remove {{.SiteBaseURL}} from the template, since you don’t know what that is.
Thank you for that, don’t know why I didn’t think of it before, I tried it before but I did not change urls in template
Now I removed {{.SiteBaseURL}} from template and changed url to css from like this /css/style.css to ../css/style.css.
but hugo server command witll try to run server with next url Web Server is available at //localhost:1313///blog/ (bind address 127.0.0.1).
This url is not working.