I tried to create a Drupal 8 child theme of Bartik. The problem is that the CSS of my child theme is loaded above the css of Bartik on all pages.

mytheme.info.yml file:

name: mytheme
type: theme
description: 'mytheme theme based on Bartik'
core: 8.x
package: custom
base theme: bartik
stylesheets:
  all:
    - css/mytheme.css

Anyone has a clue what goes wrong here?

Comments

Codenator’s picture

There in Bartik theme css calling as library that why u got your custom css first. Do this way:
create mytheme.libraries.yml

base:
  version: VERSION
  css:
    theme:
      css/mytheme.css: {}

and in mytheme.info.yml file:

name: mytheme
type: theme
description: 'mytheme theme based on Bartik'
core: 8.x
package: custom
base theme: bartik
libraries:
  - mytheme/base

happy digging

f0ns’s picture

thanks, this works perfectly. I should have checked the code of Bartik better I guess. I used the documentation as an example (https://www.drupal.org/node/2165673). I guess this needs to be updated.

Codenator’s picture

I think it going to be good hobbit now put you customs in library.
Fix documentation for js as well

rajesh.vishwakarma’s picture

I am using same code as on https://www.drupal.org/node/2165673, but my style.css is not showing on view source code.

tresero’s picture

Well that certainly doesn't work. I wish it did.