Deploying the _site folder - Problem with CSS

Hi everyone,

I build a Jekyll template and generate a _site folder. If I understand correctly from this guide (Manual Deployment | Jekyll • Simple, blog-aware, static sites), then I just need to copy everything from _site folder too my public_html folder on my server for deployment.

However, when I check the site, the content is ok, but all the CSS is broken. It seems CSS uses an absolute path, which is not included when deployment. Any idea how to solve this?

PS: I don’t update my site often, so no need to do it automatically.

Hi.

It sounds like your CSS is something like.

/assets/css/styles.css

But that is broken.

Can you supply a link to your site?
And a screenshot to show the actual error?

I don’t have enough info to know if this is a absolute vs relative or if it is about a subpath.


Your problem might be lack of forward slash. Like assets/css/styles.css will break on some pages. But /assets/css/styles.css will work.

Or

Your problem might be lack of a subpath.

e.g. you need to set baseurl: /abc in config. To make request from example.com/abc to example.com/abc/assets/css/styles.css

I have a site like that here.


Also to note that public_html can be the folder where you upload to, but that should not actual appear in your URLs. i.e. you should be able copy the contents of _site (not the directory itself) to any directory name that is served publically like public or public_html and it should work identically and the user won’t see the name of that in the URL.

1 Like

Thanks for your help.
I figured the problem. It’s quite silly.

I should set the url as mydomain.com and the baseurl as blog. (Instead of url:mydomain.com/blog)

Indeed

It should be like this.

URL gets used when doing a Production Jekyll build (helps with sitemap and rss but otherwise only comes up if you use absolute_url filter). “Domain” is a better label for URL field but anyway Jekyll uses URL.

Make sure to include protocol.

Baseurl will be used for relative URLs to make a subpath site. Empty string is fine if not using a subpath

url: https://mydomain.com
baseurl: /blog

Example of my config on a deployed site