2

I cannot seem to include my CSS and JS files from the craft/templates/ directory into my website.

I've looked at this answer - Serving CSS files from template folder - and it tells me I simply need to have a styles/styles.css folder and I use {% includeCssFile "/styles/styles.css" %} and it should work. But it doesn't. I have a similar problem with the javascript includes. {% includeJsFile "js/lodash.min.js" %} command works, but once I navigate to any other URL, it tries to include the file http://localhost/craft/news/2016/js/lodash.min.js.

My folder structure looks like this:

I'm trying to keep all my assets in this craft/templates/ folder because I created a git repo in the craft main folder.

1

1 Answer 1

2

Your example code worked for me - This may be down to using MAMP and having a config file that handles my siteUrl and assetsUrl.

There are a few questions already on Stack Exchange that relate to your folder structure and how to include assets in different templates.

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.