Main.css ignored unless modified


#1

Hi everyone,

I’m relatively new to Jekyll and I have an issue which I can’t seem to solve myself.

Every time I execute jekyll serve from shell jekyll keeps using the main.css of the current theme and ignoring my custom main.css. If I modify my main.css, then jekyll uses my css.
How can I solve this annoying issue?
Thanks

Best
P.


#2

Please provide more information about Your code. How the CSS is being loaded (in which order etc). If possible then link to repository. Also be sure that You’d always clear cache for browser or use incognito mode when making changes to code.


#3

Here is the link to the repo https://github.com/codedbypm/papaya


#4

It looks like you’re missing the head.html include. In my site, I define all CSS/JS in the head file and then include that in the base layout. For reference:


#5

But my base.html layout looks like this

<!DOCTYPE html>
<html lang="en">
  {% include head.html %}

  <body>

{% include nav.html %}

{{ content }}

{% include footer.html %}

{% include footer-scripts.html %}

  </body>
</html>

so there is a head.html included. In fact it’s taken from the gem-based theme itself, and since I do not override it, it’s not present in my repo. I tried copying it in my project but still it does not work. I always must dirty the main.css file so that jekyll loads it correctly. Why is that so?


#6

Right! I’m used to non-theme Jekyll.


#7

I think the problem could be traced to the following:

  • If an asset file doesn’t have YAML FrontMatter Dashes, its a StaticFile. Apparently, non-binary StaticFiles are loaded only when they are modified.

Resolution

I have opened a pull request at jekyll/jekyll#5918 that attempts to resolve this matter Do try the proposed solution locally at your end (use that branch in your Gemfile), and if it works, upvote on the request. Else, please leave a feedback.


#8

Thanks for the PR. That would fix my issue.