Patrick is right that Craft let's you do what you wish in your HTML templates. I think it's worth adding a small distinction to where you store your front-end assets as there are two possible locations with slightly different behavior:
- Craft templates folder
craft/templates/...
- Public folder (i.e.
public/...
)
Example folder structure:
craft/app
craft/storage
craft/templates (#1)
public/... (#2)
public/index.php
Most of your page templates will probably be managed in the first location – your Craft templates folder. If you wanted to, you could put your css and js assets in that folder too (craft/templates/assets/css
, etc.). Craft will serve your .css
and .js
as the correct file types.
However, any files that are being served from the Craft templates folder come with the overhead of being routed through Craft's index.php file and being processed by Craft, before they get delivered to the browser. This can be fine, and gives you an option to use Twig in your css or js templates if you really want to.
For most static css and js files, this probably isn't necessary. And linking to the files in the Craft templates folder incurs unnecessary overhead. Your css and js files will also work fine if you link to them in your public folder. A resource request will first check to see if the file exists in your public folder and, if a match is found, that resource will be returned to the browser immediately without ever hitting Craft's index.php
file and spinning up Craft.
The most common setups that I have seen on Craft websites follow a pattern like the following, where css, js and other static files are linked to in the public folder:
craft/app
craft/storage
craft/templates/... (dynamic templates that needs to be processed by Craft)
public/assets/... (static stuff that doesn't need to be processed by Craft)
public/index.php
The Craft docs on Routing are a good place to get an overview of how a request is routed.