StochasticNerd StochasticNerd - 2 months ago 21
Sass (Sass) Question

Styles not rendering in Jekyll site

I'm trying to get started with a blog using Jekyll. With Ruby, bundler and gems installation out of the way, I've spun up a site. The problem now is that the styles don't seem to render.
The site's src code is here, https://github.com/soumasish/Blog

I'm not sure if the problem is because the SASS isn't compiling or the site is just not able to pick up the CSS.
Any help appreciated.

Answer

I'm assuming you mean the styles aren't loading when you visit https://soumasish.github.io/Blog/, locally it looks fine.

It's requesting the CSS file at /css/main.css, which is an absolute URL. This absolute URL negates the base path of Blog, resulting in a request to:

https://soumasish.github.io/css/main.css

But the CSS file is located here:

https://soumasish.github.io/Blog/css/main.css

To fix it, you can add a baseurl option to _config.yml:

baseurl: "/Blog"

Or add that to the url setting (but baseurl is the recommended way):

url: "https://soumasish.github.io/Blog"