I am having an issue with an Invalid CSS error when I try to import TWBS Bootstrap into my bare bones Jekyll project. I asked for help within the Jekyll GitHub Discussions tab. Here is the link with all the errors, code snippets, and repo link in case it is helpful…
I came across a similar forum post where the author said that the front matter should not be inside any scss files? The docs state though that the front matter is necessary to cause Jekyll to process the .scss file as a .css file. I am using an older tutorial, so perhaps the Jekyll syntax has changed since then…
My main.scss file (located at root > assets) has the following:
---
---
@import 'bootstrap/bootstrap';
But I am getting two errors - one in VSCode { expectedscss(css-lcurlyexpected) and the other when I try to run jekyll serve
At first it was returning this error
Error: Invalid CSS after "-": expected 1 selector or at-rule, was "---" (Jekyll::Converters::Scss::SyntaxError)
on line 1:1 of assets/css/main.scss
from line 1:1 of main.scss
>> ---
^
but now it returns this:
rror: @import directive requires a url or quoted path (Jekyll::Converters::Scss::SyntaxError)
on line 1:1 of main.scss
>> @import (bootstrap/bootstrap);
^
What does it mean by “URL or quoted path”? I have quotes " " around the import and I have imported the Bootstrap SCSS files into my project (root > assets > css > bootstrap) so I do not have a URL for this import?
and the console error went away and I can "successfully run jekyl serve without an error… However, there is still no Bootstrap styling and I am now getting this error when I run jekyll serve:
[2022-04-13 13:07:04] ERROR '/assets/css/main.css' not found. The VSCode error is still present…
are you editing the file in the _site folder? if so don’t do that as that is going to be overwritten every time jekyll runs - not to mention that is for css/html stuff only so front matter is going to break things.
You only edit the files in the root folder, jekyll then takes that and renders out the _site folder.
If you happen to be using Jekyll’s minima theme, you will find the <head> area in the _includes/head.html file. You will find the <body> area in the _layouts/default.html file.
I think this is a better way to go.
Note: if you do not have an _includes or _layout folder in your site, you may want to copy that theme content into your working repo by following the Overriding theme defaults instructions here:
Thank you for your thorough reply @BillRaymond I will give that solution a try. It does make more sense to pull the CSS from a CDN rather than shipping all that code, some (or maybe even most of it) the app will not end up needing…