1

We're trying to create our very first theme in drupal 8 and we're having some problems with it.

When we try to link our custom css and try to load the page it gives us

The website encountered an unexpected error. Please try again later.

We've tried different solutions, but none of them worked and we're kinda lost.

here's our Fubiz_NJ.info.yml file

name: Fubiz_NJ
description: Website homepage reproduction
type: theme
core: 8.x
libraries:
  - Fubiz_NJ/global-styling
  - Fubiz_NJ/global-scripts
stylesheets-remove:
  - core/assets/vendor/normalize-css/normalize.css
  - core/modules/system/css/system.module.css
  - core/modules/system/css/system.theme.css
  - core/modules/views/css/views.module.css

# Define regions
regions:
  header: 'Header'
  primary_menu: 'Primary Menu'
  secondary_menu: 'Secondary Menu'
  slideshow: Slideshow
  page_top: 'Page Top'
  content: 'Main content'
  footer: 'Footer'

and here's our Fubiz_NJ.Libraries.yml file

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

global-scripts:
    version: 1.0
        js:
            js/script.js: {}

We're both new to drupal so we don't really know where to look at this point, Hope you guys can help!

  • The libraries YAML doesn't quite look right. Also, it would be great if you could provide the PHP error from the error log that is causing the site to crash. – mradcliffe Apr 11 '16 at 13:38
  • @mradcliffe here's the error "Drupal\Core\Asset\Exception\InvalidLibraryFileException: Invalid library definition in themes/custom/Fubiz_NJ/Fubiz_NJ.libraries.yml: Unable to parse at line 3 (near " css:")" – Nicolas Decroos Apr 11 '16 at 13:53
3

The libraries YAML file is not correct. In YAML, indentation matters. Additionally, spaces should be used instead of tabs.

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

global-scripts:
    version: 1.0
    js:
        js/script.js: {}
  • Wow that was it! I didn't realize YAML was that strict with spaces, thanks! – Nicolas Decroos Apr 11 '16 at 14:00
  • If you wanted to add more than one css or js to your global values how would you do that. Every attempt I try to pass more than one css or js into this yml file crashes the theme. – Patrick W. McMahon Apr 16 '16 at 4:12
  • Take a look at the bartik.libraries.yml file, @PatrickW.McMahon. – mradcliffe Apr 16 '16 at 6:24
  • found out that you must use spaces and not tabs. This is going to take some time to get use to as I have always used tabs for laying out code. – Patrick W. McMahon Apr 18 '16 at 13:44
  • could you add to your answer about the space vs tab thing so others will know as well when starting to use the new yml files. – Patrick W. McMahon Apr 18 '16 at 13:45

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.