1

I'm creating a new D8 theme and am having trouble making Drupal load the CSS that is a part of my theme. I have disabled cache and am sure I'm getting the up-to-date output.

Here's my mytheme.info.yml:

name: Mytheme
type: theme
description: 'This is a description.'
core: 8.x

libraries:
  - mytheme/global-styling

libraries-override:
  system/base: false

regions:
  header: Header
  content: Content  # the content region is required
  menu_primary: 'Menu - Primary'
  menu_secondary: 'Menu - Secondary'
  footer: Footer

Here's mytheme.libraries.yml

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

and this is the top of my html.html.twig file:

<!doctype html>
 <html lang="en">
 <head>
   <title>{{ head_title }}</title>
   <head-placeholder token="{{ placeholder_token|raw }}">
   <css-placeholder token="{{ placeholder_token|raw }}">
   <js-placeholder token="{{ placeholder_token|raw }}">
   {{ page.head }}
   {{ page.styles }}
   {{ page.scripts }}
</head>
...

The content in the YAML files is not tabbed, spaces are used.

I already spent several hours trying to figure out what's wrong and why the global.css is not being linked in the header of the html page, but I have no idea. I'll be gratefull for any help.

EDIT: I found out that my CSS do load when I use this:

{{ attach_library('mytheme/global-styling') }}

but I thought the point of referring to global-styling inside mytheme.info.yml was that I don't have to do that. Did I understand that correctly?

2
  • Is the name of the theme mytheme or logis?
    – Kevin
    Apr 27, 2016 at 14:05
  • mytheme, I corrected it.
    – Ondrej
    Apr 27, 2016 at 14:06

1 Answer 1

0

Try this. I am using this in my base theme, and it works:

global-styling:
  version: VERSION
  css:
    base:
      css/YOURCSSFILE.css: {}
1
  • No difference. I also added an edit to the bottom of my description of the problem.
    – Ondrej
    Apr 27, 2016 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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