<p>Your example code worked for me - This may be down to using MAMP and having a <a href="https://craftcms.com/docs/config-settings" rel="nofollow noreferrer">config file</a> that handles my siteUrl and assetsUrl. </p>

<p>There are a few questions already on Stack Exchange that relate to <a href="https://craftcms.stackexchange.com/questions/15310/creating-partials-outside-of-the-templates-folder/">your folder structure</a> and how to <a href="https://craftcms.stackexchange.com/questions/15663/loading-javascript-on-specific-sections-pages">include assets in different templates</a>.</p>

CC BY-SA 3.0
2016-06-27T12:03:39.023Z
2016-06-27T12:03:39.023Z
2017-04-13T12:51:00.253Z
Luke Pearce
<p>I cannot seem to include my CSS and JS files from the <code>craft/templates/</code> directory into my website.</p>

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

<p>My folder structure looks like this:</p>

<p><img src="https://i.sstatic.net/o4yiv.png" width="170"></p>

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

CC BY-SA 3.0
2016-12-20T12:37:16.783Z
Not an answer, but just wanted to point out that serving CSS/JS from the templates folder is considered a bad practice – [Brandon outlines why in his answer to the thread you linked](http://craftcms.stackexchange.com/a/3093/1098).
Mats Mikkel Rummelhoff
<templating>
Including CSS/JS assets from template folder
# Including CSS/JS assets from template folder

(Asked by: username_0 on 2016-06-27)

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](https://craftcms.stackexchange.com/questions/3092/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:

![](https://i.sstatic.net/o4yiv.png)

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

**Tags:** templating

> **Comments:**
> **username_1**: Not an answer, but just wanted to point out that serving CSS/JS from the templates folder is considered a bad practice – [Brandon outlines why in his answer to the thread you linked](http://craftcms.stackexchange.com/a/3093/1098).  

---

## 1 answers

### Answer by username_2 on 2016-06-27. Score: 2 | Accepted answer

Your example code worked for me - This may be down to using MAMP and having a [config file](https://craftcms.com/docs/config-settings) that handles my siteUrl and assetsUrl.

There are a few questions already on Stack Exchange that relate to [your folder structure](https://craftcms.stackexchange.com/questions/15310/creating-partials-outside-of-the-templates-folder/) and how to [include assets in different templates](https://craftcms.stackexchange.com/questions/15663/loading-javascript-on-specific-sections-pages).


---

