2

I would like to let my static assets (JS, CSS and images file) close to my templates files.

public/
templates/
    css/
    images/
    scripts/
    template.html

Until now, I didn't find a clean way to access these files. {% includeCssFile %} and {% includeJsFile %} works, but I get strange "compiling" issues with my javascript "templates" saying unclosed comment.

Anyway, does a clean solution, other than copying these files to public, exists ? A variable like siteUrl pointing to the right folder ?

1 Answer 1

2

The problem with putting them in your templates folder is now PHP/Craft is going to try and serve them. Meaning that you've got the overhead of PHP and Craft when trying to request every single asset instead of if they were in the public folder where Apache can instantly serve them (orders of magnitude faster).

1
  • Ok, I guess it should be directly handled by a reverse proxy, Nginx or other, to point the assets/ url to the assets folder in my Craft templates. Thanks !
    – Antoine
    Commented Jun 12, 2016 at 19:06

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.