Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Custom css in style.csss of base theme or created subthemes don't appear to be loading/overriding.
Comments
Comment #2
markhalliwellYou have to change the library name of your sub-theme. The overrides only load if you're using the CDN. If you're using the LESS starterkit, you must compile it manually.
Comment #3
3dnathaniel CreditAttribution: 3dnathaniel commentedI am using CDN so shouldn't it be loading style.css for overrides by default?
Comment #4
markhalliwellYes, overrides.css are in fact loading. I would know, I've been looking at it loading in a CDN sub-theme ever since I fixed it here: http://cgit.drupalcode.org/bootstrap/commit/src/Plugin/Alter/Css.php?id=...
As far as a custom sub-theme style.css, again, you just have to make sure your library names and css paths are correct and rebuild the cache for it to load properly (which falls into basic library/asset handling in 8.x, not a specific problem with this project).
Comment #5
cristiroma CreditAttribution: cristiroma at Eau de Web commentedHi @markcarver,
Sorry I'm a little bit lost here, I am starting with CDN starter kit and I have tried to edit css/styles.css there and the file is not loaded. It's still not clear how to make the file load.
Edit: Removed the suggested code as it's not working.
Comment #6
cristiroma CreditAttribution: cristiroma at Eau de Web commentedTo anyone coming here from search engine, if you encounter the issue described above, make sure you pay attention when you create the theme from starterkit. Precisely the following steps:
1. Rename THEMENAME.starterkit => mytheme.info.yml
2. Inside the file mytheme.info.yml make sure you have:
3. In your mytheme.libraries.yml you have:
I personally missed step 1. by removing the THEMENAME.starterkit and adding my own custom blank info that was missing the "libraries" section.
Comment #7
sillo CreditAttribution: sillo commentedDefinately not working as designed.
I have used the CDN starterkit, renamed all the files accordingly (mytheme.info.yml, mytheme.libraries.yml) and changed the libraries path to "mytheme/global-styling". STYLE.CSS IS NOT LOADED!
I did more than 50 subthemes in D7, like a walk in the park. D8 i can't even do 1.
I re-checked i did everything correct (changed the name of the theme in the info file etc.) and it still doesn't load STYLE.CSS.
Im giving up on this new theming system.
Comment #8
Lalas CreditAttribution: Lalas commentedI also faced this issue even after checking for the correct THEMENAME is updated wherever it is required. One misconfiguration i believe i did was
After Opening
THEMENAME/config/schema/THEMENAME.schema.yml
The first line to be updated is THEMENAME and the second one is THEMETITLE which are different each other. The THEMENAME is the machine readable name of the subtheme (name of the subtheme folder) and the THEMETITLE is the title of the theme referred in the THEMENAME.info.yml file
Then if you are using sass satrterkit
go to your subtheme folder create css folder and compile stlyle.sass
If you are using less satrterkit
go to your subtheme folder and compile stlyle.less
Comment #9
moufmouf CreditAttribution: moufmouf commentedI also faced the same issue.
For us, the problem was that we had a "theme" that had the same name as a "module".
This completely screws Drupal 8 (I'm using Drupal 8.2).
Simply disabling the module enables the CSS of the theme back.
Comment #10
riskogab CreditAttribution: riskogab commentedThanks moufmouf,
That was the problem.
Comment #11
tnfno CreditAttribution: tnfno commentedHad the same problem and the issue where that the instructions for makeing a subtheme placed the css file in the folder /stylesheets/style.css while the libraries file said it was in /css/style.css. Updating the libraries file fixed it...
Comment #12
millionleaves CreditAttribution: millionleaves as a volunteer commented#11 was the solution for me, using the SASS starterkit.
The style.css file was compiling correctly, but the style.css file was in stylesheets, when the libraries file said it was in css. Changing the libraries file solved the problem.
Is this a bug or a misconfiguration on my part?
Comment #13
markhalliwellIt's a misconfiguration on your part.
By default CSS preprocessors will likely spit out the compiled source to the same directory of the source file. You must configure your compiler to output to the correct directory, per the instructions.
Comment #14
leveller CreditAttribution: leveller commented#8 pointed me in the right direction; I had a profile with the same name as my theme. Well spotted!
Comment #15
gerrit.michiels CreditAttribution: gerrit.michiels commentedI'm also experiencing this problem. The style.css file does not seem to load even though I'm rather sure everything is configured correctly. I checked of every tip above here. What am I missing?
Comment #16
kkalaskar CreditAttribution: kkalaskar commentedIf all files are proper and page source showing stylesheet path sites/files/css it means files are cached and make sure aggregation unchecked under /admin/config/development/performance.
Comment #17
ruizuser CreditAttribution: ruizuser commentedDear friends, I'm having a similiar issue with my own custom style.css file in drupal 8. I've created a child theme from yorkshire theme and I've tried everything, but in one of my last tests, I renamed css and js folder to random names (asdasd and zxczxc), and surprisingly, it seems drupal is only looking for the javascript file, not the css file, giving me this error:
Warning: file_get_contents(themes/custom/comite/js/comite-style.js): failed to open stream
These are my info and libraries files:
comite.info.yml
type: theme
description: 'Tema para el comite'
core: 8.x
package: Custom
version: VERSION
base theme: yorkshire
libraries:
- comite/comite-style
regions:
brand: Site Branding
header: Header
top: Top
content: Content
bottom: Bottom
sidebar: Sidebar
footer: Footer
navbar_right_notifications: Navbar Right Notifications
features:
- favicon
- logo
and comite.libraries.yml:
comite-style:
version: 1.x
css:
base:
css/comite-style.css: {}
js:
js/comite-style.js: {}
Any help is welcome!
Many thanks in advance!!
Comment #18
Kitfey CreditAttribution: Kitfey commentedI also use the SASS starterkit and everything loads perfect.
But, I can't load custom js files. Have someone successfully applied js files in sass subtheme?
Comment #19
noblescz CreditAttribution: noblescz commentedIn Drupal 9 there is a change! For me /themes/bootstrap_business/ moved to /themes/contrib/bootstrap_business/
Comment #20
mehuls CreditAttribution: mehuls commentedI was using same name for theme and module both. so library was not getting loaded.