Standard directory structure

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

All web sites have different directory structures, and different
directory names, ie:

www - images - css - javascript

www - i - c - j

www - i - css -js

www - includes - model - view - controller - sql

www - _includes - _model - _view - _controller - _sql


Is there a convention that people should respect in structure and
It would make it easier when you have to update a web site that you
aren't the author...

Re: Standard directory structure

Charles wrote:
Quoted text here. Click to load it

Great question.

Re: Standard directory structure

Charles wrote:

Quoted text here. Click to load it

There is no convention for web sites, and as web sites are pretty
independent, then there's no need for one or real benefit to it. There
is good practice though, which states some of the reasons why some
layouts are better than others.

* Lowercase everywhere. Pick one delimiter character for use in
filenames ("-" or "_", not " ") and stick with it. Don't abbreviate. If
you do abbreviate, be consistent. Fix spelling errors as soon as
they're spotted, no matter what the cost. It's still cheaper now than

* You have the power to do almost anything and make it work. You have
the laziness to want it simpler. Do the _minimum_ possible, not the
maximum. You'll make fewer stupid errors that way.

* There are three structures to a website: logical, URL and directory.
You can present the same structure through all (the default) or you can
mangle things between layers.

** You need a good logical structure, or users can't navigate.

** A good URL structure that models the logical structure allows
improved navigation to skilled users, particularly for breadcrumbs and
a conceptual model of where they are in the site. A database-driven
site may easily have a complex logical structure, yet no apparent
structure in the URLs at all.

** Directory structure is hidden from the users and is only relevant to
the webmaster. If it models the URL structure, then this is easy (and
that's usually a good idea). If it doesn't, for whatever reason, then
there are still techniques to map URLs onto directories in a flexible
manner. In particular, two URLs might be made to point to the same

* Directory structure, especially for web apps, is often rigidly fixed
by the platform. Techniques like Struts might help to prevent the URL
structure from becoming flat and confusing as a result.

* Cool URLs don't change

* URLs to assets referenced from outside (either deliberately by RSS or
just by people exchanging links) really shouldn't change.

* Don't have a directory structure of "this week". If things do change,
then give the directory a static name (maybe a datestamp) and make the
links to "this week" point to it. This is a good use for mapping
logical URLs onto a different physical directory structure (remember
that .htaccess can be dynamic too, especially if it's only daily).

* Make things that are possibly sortable, sortable (and easily). Use
YYYYMMDD for directory names, not mm-dd-yy.

 * Assets that are shared across multiple pages (CSS, page furniture
images, shared JS) should be in simple URL structures directly off the
root. This allows them to be addressed by simple consistent URLs from
any page that needs them.

* A functional division between assets is good (e.g. the pages for the
newsfeed section are all located together).  An attributional division
is bad (there's no point putting all the photos together just because
they're JPGs, nor is there any point in separating GIF & JPG)

* Give things functional names, not implemenation names. Call them
"images", not "JPGs".

* .html, and always .html  Or else .htm and always .htm. Doesn't matter
which, but be consistent. Same for .jpg

* Think. If you do something, ask why you're doing it. Ask how else you
could possbly (maybe badly) do it, and if that's better or worse. What
will you do to the site in the future? What effect will that have?

* Keep assets like images with the page that uses them. If they're used
from several places, then either keep them with one page, or move this
collection to its own directory. If you use a few images from all over
the site to make up the homepage, then either reference them across the
site, or copy them into a duplicated set for the homepage. Why do you
do this? Will you ever want to change these images? Regularly? All

* Keep file permissions consistent within directories. If some files
need protection, move them somewhere else.

Quoted text here. Click to load it

This just doesn't happen much. Do what's logical for the context, not
copy whatever you did last time, regardless.

Site Timeline