Search code examples
jekyll

Jekyll ignores css rules


I recently revived my old Jekyll project started with Jekyll 3.x (now using Jekyll 4.2 and I forgot a lot). The generated site is OK if browsed with jekyll serve command, but if later I manually enter _site folder and click index.html the site ignores css rules and links are broken.

This makes me nervous how to deploy the site. What I'm doing wrong?


Solution

  • Your site is served from a development web server when you run jekyll serve. I'm assuming by click index.html, you mean you are opening the file in your web browser - this won't work well with the absolute URLs Jekyll creates.

    You can see the difference in the URL bar: one will say http:// and the other will be file://, a URL like /css/main.css will likely only work through the web server (i.e. jekyll serve).

    Assuming you are deploying the site to a web server, and it works with jekyll serve, I'd guess it's fine. I can't be sure, but in any case, You should probably back up what's on the server currently though so you can restore it.