0

I am trying to learn Drupal 8 theme development. I am trying to create basic theme My Folder structure

|-themes
  |  |-custom
  |  |  |-contra
  |  |  |  |-css
  |  |  |  |  |-style.css
  |  |  |  |-contra.info.yml
  |  |  |  |-contra.libraries.yml

My contra.info.yml is as follows:

name: contra
description: 'Drupal 8 starter theme'
type: theme
core: 8.x
libraries:
   -'contra/global-styling'

My contra.libraries.yml is as follows:

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

I have cleared the cache in Admin->Configuration->Development and also refreshed my browser but I dont see the style.css loaded in view source.

3
  • As shown, your .libraries.yml file has incorrect spacing. Does that reflect your file, or just the copy and paste? – Prestosaurus Mar 29 '19 at 14:56
  • yes that reflects my file. But I tried changing space. Where should I give space? – Abhilash Narayan Mar 29 '19 at 14:57
  • Looks like you may have 3 spaces when adding your library to your .info.yml file as well. – Prestosaurus Mar 29 '19 at 15:16
0

Try adjusting your spacing. 2 spaces are required.

.info.yml:

name: contra
description: 'Drupal 8 starter theme'
type: theme
core: 8.x
libraries:
  - contra/global-styling

.libraries.yml:

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

Also, take a look at https://www.drupal.org/docs/8/theming/adding-stylesheets-css-and-javascript-js-to-a-drupal-8-theme

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.