I'm quite sure the problem is my paths to .css files in the _layout.html file but just can't get my head around it.

I've got this in my _layout.html. It works for home page and news page.

{% includeCssFile "css/material.css" %}
{% includeCssFile "css/main.css" %}

But then I get the unstyled page when viewing a specific news entry. _entry.html is not extending _layout.html

My CSS files are on the same level as my templates. What should these paths be?


News/_entry should definitely be extending _layout (or any layout you want to use). That's how it's setup when you download a fresh copy of Craft as well.

{% extends "_layout" %}

The CSS file should not be in the templates folder (that's only for twig templates), but in your web root which is the same folder as index.php. In your case that would probably be something like public/css/material.css and public/css/main.css Also make sure that any assets used in these CSS files are located in that folder instead of the templates folder.

Unless these CSS files are specific to the news entry template I'd also include them in the layout file.

  • That was exactly what I needed. I put the css in the public and used the full http:// path. Thanks.
    – Miksu Aaja
    May 31 '16 at 18:24

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.