2

I'm trying to make a Drupal 8 theme and no matter what I do, the stylesheet I have won't render. Here's my libraries.yml file:

global-styling:
version: VERSION
css:
theme:
  css/layout.css: {}

and here's my info.yml file:

name: My Test Blog
type: theme
description: 'My test theme description'
package: Custom
core: 8.x
libraries:
  - MyTestBlog/global-styling   
stylesheets-remove:
  - '@classy/css/layout.css'
  - core/assets/vendor/normalize-css/normalize.css

regions:
  header: Header
  content: Content
  stylesheets: 
    all:
        - css/style.css

Any ideas?

  • *.info.yml it should your theme machine name. example libraries: - mytestblog/global – Aryashree Pritikrishna Apr 13 '16 at 2:46
1

Be aware of indent properly (only 2 spaces, not TAB):

[theme_name].libraries.yml:

global-styling:
  version: VERSION
  css:
    theme:
      css/layout.css: {}

[theme_name].info.yml

name: My Test Blog
type: theme
description: 'My test theme description'
package: Custom
core: 8.x
libraries:
  - MyTestBlog/global-styling   
stylesheets-remove:
  - '@classy/css/layout.css'
  - core/assets/vendor/normalize-css/normalize.css

regions:
  header: Header
  content: Content
  stylesheets: 
    all:
      - css/style.css
|improve this answer|||||
  • I tried this with no success. – kriskendall99 Jun 11 '15 at 0:01
0

The theme block in libraries info should be indented and the MyTestBlog/global-styling should be in lowercase since the "MyTestBlog" is the machine name of your theme and I doubt your files are named MyTestBlog.info.yml ... And the stylesheets part of the regions don't make any sense.

|improve this answer|||||
  • 1
    Alright. So, I adjusted my code and I still can't get my stylesheet to render. Any other ideas? – kriskendall99 Jun 2 '15 at 11:22
0

I solved the problem. The problem was that the name of my style directory was not the same as the name of my libraries and info files. What I mean is that before, I was doing something like naming my file "mytestblog.info.yml" and then trying to link to myblogsite/global-styling. Once I changed myblogsite/global-styling to mytestblog/global-styling, my stylesheet rendered.

|improve this answer|||||
  • too bad :( i'm having the same issue, but all names match :((( – Tom Roggero Sep 9 '16 at 16:45
  • FIXED IT! everything was fine but had to visit /core/rebuild.php (I guess I didnt create the files in the right order, since I have local settings for dev enabled) – Tom Roggero Sep 9 '16 at 17:00
0

My Drupal 8 theme CSS was loading on my local MAMP environment, but not on my Ubuntu server... Permissions issue. This was easy to check by trying to view the CSS file listed in the HEAD of the HTML file via the browser URL, which gave me a 403 error.

I needed to chown -R myuser:www-data my CSS file directory, and that fixed it.

|improve this answer|||||
0

TIP: Conflict when Module with same name as Theme!

Just in case someone else runs into this, if you have a module with the same name as your theme (xxx, for example), the xxx.libraries.yml file in your theme folder is ignored. Instead, Drupal looks at the xxx.libraries.yml file in your modules folder. Any files referred to by it (css, js, etc.) are also loaded from the modules folder and its subfolders, not from the themes folder.

|improve this answer|||||

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.