Skip to main content
replaced http://craftcms.stackexchange.com/ with https://craftcms.stackexchange.com/
Source Link

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 folderServing 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.

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.

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.

Embedded the image (instead of linking it) plus edited wording & formatting for clarity
Source Link

Including CSS/JS assets from template folder

I've been trying to do this really simple thing and for some reason I can'tcannot seem to get it working. All I want to do is to be able to include my cssCSS and jsJS files from the templatecraft/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.cssstyles/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/templatescraft/templates/ folder because I created a git repo in the craft main folder.

Including CSS/JS assets

I've been trying to do this really simple thing and for some reason I can't seem to get it working. All I want to do is to be able to include my css and js files from the template 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 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.

Including CSS/JS assets from template folder

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.

Source Link
CJX3711
  • 23
  • 1
  • 3

Including CSS/JS assets

I've been trying to do this really simple thing and for some reason I can't seem to get it working. All I want to do is to be able to include my css and js files from the template 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 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.