-3

I have created a bootstrap sub-theme in Drupal 8 its work fine but my custom CSS file style.css is not linked to it. It shows this text on the top of the preview page.

global-styling: css: theme: css/style.css: {}

What is the proper way to link custom CSS to my Drupal 8 site?

1

Here is an example in (your_custom_sub_theme.libraries.yml)

global-styling:
  css:
    component:
      css/my-custom.css: { weight: 220 }
      css/my-custom2.css: { weight: 221 }
      css/my-custom3.css: { weight: 222 }

  js:  
    js/my-custom.js: {}
    js/my-custom2.js: {}

Do NOT change the indents.

(the weight is optional)

In your_custom_sub_theme.info.yml you need:

# Defines libraries group in which we can add css/js.
libraries:
  - your_custom_sub_theme/global-styling
  • I have done all these things but it is still shoe this code on the top: global-styling: css: theme: css/style.css: {} – Shakil Ahmad Sep 27 '17 at 11:04
  • 1
    Maybe you could post your ...libraries.yml and ...info.yml in your question here. (Also be accurate with the indents.) – eye-wonder Sep 27 '17 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.