Search code examples
csssassjekyllstatic-siteyaml-front-matter

Jekyll: Error: This file is already being loaded + unrecognized front matter


I have a jekyll based blog. When I try to build it I get this error:

...
     Generating...
       Jekyll Feed: Generating feed for posts
Warning on line 1, column 1 of /home/john/Projects/blackblog/assets/css/index.sass:
This selector doesn't have any properties and won't be rendered.
  ╷
1 │ ---
  │ ^^^
  ╵
Warning on line 2, column 1 of /home/john/Projects/blackblog/assets/css/index.sass:
This selector doesn't have any properties and won't be rendered.
  ╷
2 │ ---
  │ ^^^
  ╵
Error: This file is already being loaded.
  ┌──> /home/john/Projects/blackblog/assets/css/index.sass
4 │ @import index, font, basic, layout
  │         ^^^^^ new load
  ╵
  ┌──> /home/john/Projects/blackblog/assets/css/classes.sass
1 │ @import index, highlight
  │         ━━━━━ original load
  ╵
  /home/john/Projects/blackblog/assets/css/index.sass 4:9    @import
  /home/john/Projects/blackblog/assets/css/classes.sass 1:9  root stylesheet
  Conversion error: Jekyll::Converters::Sass encountered an error while converting 'assets/css/classes.sass':
                    This file is already being loaded.
...

This code of whole site: github.com/yagarea/blackblog.

What should I fix to make my site build ? Thank you for help


Solution

  • Cause of this issue was that I had file name index.sass in _sass and in assets. This was not issue in until jekyll-sass-converter version 3.0.

    I renamed one file to main.sass. I brought a lot of other issues but it was easy fix because build log tells you what to do to fix it.


    Not really a bug. This is how it happened:

    1. index.sass has front matter. Jekyll read file as string, process and remove the front matter, then start to compile an input “string”.

    2. index.sass imports index.sass, according to sass spec, the relative import of itself hits before load path, and now we are importing the same file which technically is a circular import. When sass read the same input directly from disk, it knows nothing about the Jekyll front matter and would give up with a syntax error.

    One way to address it can be write a custom importer that checks for front matter in each imported partials, and compile it with Jekyll before read as sass partials. However, this has significant drawbacks that isn’t worth doing:

    1. Jekyll’s sass implementation has never allowed partials to have front matters.
    2. Allowing front matter in partials would lead to slower compilation performance as every partial need to be preprocessed by Jekyll, and then passed through protobuf via stdio as a string rather than dart-sass-embedded directly read file from disk.
    3. Even if we allow front matter in partials, it would still be circular import, and user would just get a different error message.

    Source: github.com/jekyll/jekyll/issues/9265