# Bootstrap Import throws Invalid CSS error

**URL:** <https://talk.jekyllrb.com/t/bootstrap-import-throws-invalid-css-error/7238>\
**Category:** Help\
**Created:** [April 13, 2022, 5:04pm UTC](https://talk.jekyllrb.com/t/bootstrap-import-throws-invalid-css-error/7238 "2022-04-13T17:04:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Isaac-Tait](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/isaac-tait/32/4583_2.png) [@Isaac-Tait](https://talk.jekyllrb.com/u/Isaac-Tait)\
**Post date:** [April 13, 2022, 5:04pm UTC](https://talk.jekyllrb.com/t/bootstrap-import-throws-invalid-css-error/7238/1 "2022-04-13T17:04:30Z")

</div>

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](https://github.com/jekyll/jekyll/discussions/9028) is the link with all the errors, code snippets, and repo link in case it is helpful…

I came across a [similar forum post](https://talk.jekyllrb.com/t/invalid-css-after-expected-1-selector-or-at-rule-was-sassc-syntaxerror/5802/2) 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:

```auto
---
---
@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

```auto
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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![Isaac-Tait](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/isaac-tait/32/4583_2.png) [@Isaac-Tait](https://talk.jekyllrb.com/u/Isaac-Tait)\
**Post date:** [April 13, 2022, 5:10pm UTC](https://talk.jekyllrb.com/t/bootstrap-import-throws-invalid-css-error/7238/2 "2022-04-13T17:10:56Z")

</div>

I updated my `_config.yml` file from:

```auto
sass:
  sass_dir: assets/css

```

to:

```auto
sass:
  sass_dir: ../assets/css

```

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…

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [April 13, 2022, 5:27pm UTC](https://talk.jekyllrb.com/t/bootstrap-import-throws-invalid-css-error/7238/3 "2022-04-13T17:27:08Z")

</div>

> [@Isaac-Tait](#):
>
> My `main.scss` file (located at `root > _site > assets` ) has the following:

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.

---

<div class="post-metadata">

**Author:** ![Isaac-Tait](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/isaac-tait/32/4583_2.png) [@Isaac-Tait](https://talk.jekyllrb.com/u/Isaac-Tait)\
**Post date:** [April 13, 2022, 5:30pm UTC](https://talk.jekyllrb.com/t/bootstrap-import-throws-invalid-css-error/7238/4 "2022-04-13T17:30:56Z")

</div>

Thank you that was a typo. I am not editing the `_site` folder. I will edit the OG blog post 🙂

---

<div class="post-metadata">

**Author:** ![BillRaymond](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/billraymond/32/5963_2.png) [@BillRaymond](https://talk.jekyllrb.com/u/BillRaymond)\
**Post date:** [April 13, 2022, 5:44pm UTC](https://talk.jekyllrb.com/t/bootstrap-import-throws-invalid-css-error/7238/5 "2022-04-13T17:44:40Z")

</div>

I am not familiar with Bootstrap, but looking at the documentation, you will probably want to use bootstrap on _any_ page. Is that correct?

Reading the Bootstrap introduction here:

> **[Introduction](https://getbootstrap.com/docs/4.3/getting-started/introduction/)**
>
> Get started with Bootstrap, the world’s most popular framework for building responsive, mobile-first sites, with jsDelivr and a template starter page.

It looks like you want to add this to the `<head>` area of your site:

```auto
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

```

And then add the following (or some variant) within the `<body>` area of your site:

```auto
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.7/dist/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

```

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:

> **[Themes](https://jekyllrb.com/docs/themes/#overriding-theme-defaults)**
>
> Jekyll has an extensive theme system that allows you to leverage community-maintained templates and styles to customize your site’s presentation. Jekyll themes specify plugins and package up assets, layouts, includes, and stylesheets in a way that...

---

<div class="post-metadata">

**Author:** ![Isaac-Tait](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/isaac-tait/32/4583_2.png) [@Isaac-Tait](https://talk.jekyllrb.com/u/Isaac-Tait)\
**Post date:** [April 21, 2022, 2:17pm UTC](https://talk.jekyllrb.com/t/bootstrap-import-throws-invalid-css-error/7238/6 "2022-04-21T14:17:57Z")

</div>

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…
