Leading slash in all links in fresh install

I’d like to setup a jekyll site that I want to deploy via FTP to my website. But in the folder _site all links are broken, I assume it is because there is a leading slash at the beginng of every relative link e.g. “/assets/main.css” (notice the leading /). If I get rid of this leading slash manually it works. The page also works fine when I use jekyll serve. I found one solution online from a few years ago that suggested updating, but now I have the latest version (Ruby 3.0.0 and Jekyll 4.2.1) and I still have the same problem. I have a completely fresh install, so I did not change anything from the standard setup of jekyll. The baseurl is empty, e.g. set to “”. Any ideas what I am doing wrong?
Thanks and best regards

In what context are you seeing these broken links? Are you viewing the site directly with file: URL (i.e. opening HTML files directly from a file browser (Finder/Explorer/etc))?

You mention that the site is fine when running jekyll serve. With jekyll serve, you would view the site with an http: URL (e.g. http://localhost:4000) which connects to Jekyll’s built-in mini-web-server. By default, Jekyll generates files in _site, which are meant to be served by a web server, not directly opened as file: URLs. Do you have a specific need to access the files offline with file: URLs?

Thanks for the quick reply. Yes: I view the file directly as a file from a file browser. You can have a direct look at https://jakiva.de/merkblaetter/. This is another project (so it has a few altered files) But it also l has this problem of the leading slash, for example in line 21.

I think it is cause you are serving out of a sub folder on the live sight - a url that starts with a / is going to look at the root not the sub folder. This is where baseurl comes in handy, you can add that as a prefix to your urls if you need to serve from a sub folder (GH does this for project repos).

If you are viewing files locally with out a webserver you will have issues but with a webs server you won’t.

1 Like

Thank you very much. I got confused (once again) with the baseurl and url command. Setting the url and put it directly live did the trick…