0

I have been working with a project where style overrides are written at _site/assets/main.css . I am trying to add another css file mystyles.css but not able to make it work.

This is the project structure:

.
├── 404.html
├── Gemfile
├── Gemfile.lock
├── README.md
├── _config.yml
├── _includes
│   ├── head.html
├── _posts
│   └── 2023-01-21-abc.md
├── _site
│   ├── 2023
│   ├── 404.html
│   ├── README.md
│   ├── about
│   │   └── index.html
│   ├── assets
│   │   ├── main.css
│   │   ├── main.css.map
│   │   ├── minima-social-icons.svg
│   │   └── mystyles.css
│   ├── feed.xml
│   ├── index.html
│   ├── jekyll
│   └── privacypolicy
│       └── index.html

This is _includes/head.html content:

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  {%- seo -%}
  <link rel="stylesheet" href="{{ "/assets/main.css" | relative_url }}">
  <link rel="stylesheet" href="{{ "/assets/mystyles.css" | relative_url }}">
  {%- feed_meta -%}
  {%- if jekyll.environment == 'production' and site.google_analytics -%}
    {%- include google-analytics.html -%}
  {%- endif -%}
  {%- include onesignal.html -%}
</head>

In is what I get in browser's devtool's Source's "Page" tab:

top
├── mysite.io
│   └── assets
│        └── main.css

ishandutta2007
  • 16,676
  • 16
  • 93
  • 129
  • 2
    The `_site` directory is generated when you build your site, editing things in it rarely makes sense. The `main.css` file comes from your theme, which might be a locally available Gem, or a remote theme; that's set in your `_config.yml`. For overrides, you want to create `mystyles.css` in an `assets` directory at the root of your project, from where it will be copied to `_site`. – Benjamin W. Jul 12 '23 at 04:05
  • 1
    @BenjaminW. got it . Thanks :) – ishandutta2007 Jul 12 '23 at 04:14

1 Answers1

1

As @BenjaminW mentioned _site/assets/mystyles.css has to be moved to assets/mystyles.css and now it works fine.

ishandutta2007
  • 16,676
  • 16
  • 93
  • 129