0

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?

3 Answers 3

2

If the path of your style sheet is correct then try to clear cache from admin panel and then check.

1
  • I do this every time I modify my files. The problem lies within my code somewhere. Thanks for the advice, though. Commented Jun 2, 2015 at 11:25
0

The problem is with your libraries.yml file (if the indentation is as shown above). Indentation is important in any yml format file and the above file will not be read correctly. Below is the correct indentation:

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

The info.yml file also contains reference to stylesheets property, which should be removed. The stylesheets property has been removed as of Drupal 8.0.0-beta11, only libraries are used now.

3
  • Well, I directly copied and pasted your libraries file and I removed the stylesheet property from the info file and it didn't work. Commented Jun 14, 2015 at 16:49
  • I assume you have verified that the css file is in the "css" sub folder of the theme folder and you cleared the cache after the changes. I also assume the theme has been installed. One thing I notice in your info.yml file is that you haven't specified "classy" as the "base theme". This is needed unless you are building your theme from scratch.
    – Alma
    Commented Jun 14, 2015 at 17:49
  • You're correct. I have verified that the css is in the "css" folder, I cleared the cache and installed the theme. I didn't, however, set classy as the base theme. I'll try that. Commented Jun 14, 2015 at 21:46
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.

Your Answer

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

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