I'm just starting with CI, and am not sure where things such as css, js, images should go.

Outside the whole system folder seems ok, but that means everything is seperate. Inside mean s the filepaths are longer and I'm worried that it might mess things up.

What's the official line on this?

+7  A: 

I usually put separate folders at the root level, so I end up with a directory structure like this:


Seems to work for me - when you use site_url(url), the URL it generates is from the root, so you can use site_url('css/file.css') to generate URLs to your stylesheets etc.

Phill Sacre
Ah, that makes sense. I wanted to be able to use site_url, so this makes sense.Thanks!
Rich Bradshaw

I hate having so many directories at the root level, so I use /public and use htaccess to rewrite /scripts to /public/scripts and so on.

+1  A: 

I find it best to keep the assets on the root level. You can use <?=base_url()?> to echo the full root of the site. In the config file, you set up the root of the website. This statement just echoes that out.

Because of this, you can use includes like this:

<link href="<?=base_url()?>/css/style.css" rel="stylesheet" type="text/css" />

anywhere in your code, and it will still get

Click Online Design

There's a article/FAQ that discusses this in CI's wiki. It seems a good way to setup you application.


thank u so much for this solution i am bothering about base url now you have provided me best solution thanks for it

hamza khan
+1  A: 


base_url() actually includes the trailing slash so you'd want: base_url() . 'css/name.css';
Mitchell McKenna
ok.ok.thanks .i know but i m forgot to put it