views:

164

answers:

6

Do you try to keep it simple and have a root folder and then 1 folder for images, javascript, flash, etc? What do you normally call your folders? Do you give your files naming conventions?

+2  A: 

It depends on the project but I generally go with js/, img/, and fl/. Sometimes I divide root into code/ and content/, but I think that may be overkill. As far as naming convention, I usually have my images perpended with the name of the page they are generally embedded on. If they are on every page, I go with something like global_ or all_. I hope that helps...

cpatrick
+2  A: 

If there are many images then a folder for them is useful, however I tend to have 1 JS file, 1 or 2 CSS.

The most useful thing I think is to mod_rewrite all the pages, like stackoverflow does.

Nerdling
+3  A: 

I keep it simple, but then my web site doesn't need things that cause complexity. In general, each web page has a name that corresponds to a folder on disk and that folder contains all of the things needed to display that page. The hierarchy of the web site matches the hierarchy on disk.

Les
+1  A: 

It really depends on how many pages your site has. Early on, it may seem like a good idea to simply drop all the pages in the root. Later on, when you have 120 unrelated files sitting there, you may start kicking yourself.

I tend to put together a simple 1-deep hierarchy, broken down by site area. /forums, /photos, /account, etc. I've learned from experience that your page count will tend to grow a lot higher than you anticipated. And I've learned from experience that it just plain sucks to move pages out of the root and into a sensible structure once they have external links. Best do it right from the start.

Jason Kester
+3  A: 

not a standard way.. but from my experience, I come up with this structure:

root/
 -> images/
      -> <subfolder>
      -> upload
 -> js/
 -> css/
 -> data/
 -> docs/
 -> download/
 -> mme/
 -> subpages/
 -> temp/
 -> siteadmin/

root: all 1st level file located there
images: all images. if images for subfolder, then another level there with the same name.  upload is for uploaded images.
js: javascript
css: css
data: some raw data if needed
docs: word doc or pdf for download
download: something that for ppl to downlaod...
mme: other multimedia files. e.g. flash, movie.. soudn clips.etc.
subpages: 2 or subsequent level pages. organized in different folders
temp: any testing page store there.  private, not public.
siteadmin: if you have an admin site.
Murvinlai
+1  A: 
root
+-+ include
  +-- cache
  +-- script
  +-- css
  +-- images

This directory is of course not externally acessible.

Why all under include? Because none of these media files are served directly. They all go through a script that:

  • Compacts all the CSS files into one file;
  • Compacts all the Javascript into one minified file;
  • Writes those versions to the cache directory;
  • Timestamps css, js and image files and sets the expires header to far in the future;
  • Keeps cached copies of the compacted js and css files in the cache directory; and
  • All references to those files goes through an auto version function that uses the last modified time to change the URL to control when the client gets a new copy (eg /css/screen.1234567890.css), similar to what SO does with its query string on such files.

The above can speed up a site significantly.

The rest of the directory structure will mirror the menu structure of the site. If there is an "Orders" top level menu items with a submenu then you can bet you'll find an accounts directory under the root directory.

All this makes the site very, very predictable if someone else needs to come and maintain it. It's extremely important that someone else is able to find their way around.

cletus