I'm trying to figure out the best place to keep my one master CSS file in craft.

I had the CSS linked in my template as

link rel="stylesheet" href="../craft/css/master.css">

But now Blog entries can't get to it, as they are looking in www.domain.com/index.php/blog/craft/css/master.css now.

Is there a better place to put the CSS, or a better way to link to it in templates?

  • Are you referring to the site's CSS or like special CSS you wrote to edit the way something looks in the CMS?
    – Ryan
    Sep 29 '17 at 22:05

In most cases, the best place to store CSS is in a publicly accessible directly, not managed by Craft at all. Such as:


Storing your CSS and other front-end assets outside of Craft reduces the overhead of accessing those files. While Craft allows you to store css files in your Craft templates folder, there is additional overhead to access those files as they need to be processed by Craft.


I had a similar issue...my Craft3 blog pagination was losing the link to my main.css file after the first page, so all content would show but styling disappeared after the main blog index page. As suggested above, I now have my css.main in /web/css/main.css, and all of the pagination and styling works perfectly.


As Ben said, you want them in the public folder. Also, you may want to use the Twig tag {% includeCssFile ...%) instead of the HTML <link rel="stylesheet" ...>.

It outputs the same way, but it works better once you start having different template folders on your site. Documentation can be found here: https://craftcms.com/docs/templating/includecssfile

  • I didnt know about the includeCSSFile. I ended up changing my css src to ../public/master.css so that all my other templates could access it
    – kingkelly
    Oct 4 '17 at 2:28

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.