Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Web folder structure?

Featured Replies

Hi people,

 

I was just interested how people structured their website folders?

 

I usually have the following folders

 

/CSS (containing style sheets)

/Images (containing Images)

/Includes (containing the header and footer which is usually linked to using SSI or PHP).

 

I than have all the pages in the _root.

 

I always figured their must be a better way of setting this out (having all the pages in the same folder can get messy as it grows)

 

I have tried other ways such as splitting up the pages into other folders/categories but I found it to be a pain having to change the links to images, css, includes etc. on different located pages.

 

Does anyone have a method they would like to share?

/css

/img

/js

/php

 

and the img folder may be split up into different dirs depending on whether there are a lot of images or not.

 

I wouldn't capitalise the first letter of each directory like you do, it would cause problems for me :)

  • Author

opps I don't capitalise them that's just a reaction when typing.

I keep my style sheets in the same folder as my html files, is that wrong? should they be kept in /css ?

Pretty much the same as everyone else here...

 

/images

/includes

/js

/css

/docs (for downloadable pdf's, word docs etc)

 

 

I have tried other ways such as splitting up the pages into other folders/categories but I found it to be a pain having to change the links to images, css, includes etc. on different located pages.

 

Does anyone have a method they would like to share?

 

Just call your images and other files putting a forward slash in front on the url, ie

 

<img src="/images/myimage.gif" />

 

This then assumes the file is located relative to the root folder, eg [root]/images/myimage.gif. You can use this method for any sort of file and avoids the hassle of linking content in subfolders.

  • Author
Just call your images and other files putting a forward slash in front on the url

 

Oh right,

 

How I didn't know that I don't know!!!

 

So no matter where my html file is even if it is three directories deep, all I would need to do is put a forward slash in front of the path (to the css for example) and it will assume it starts form the root,

 

now that's the answer I was looking for!

 

I had used absolute linking to get the same effect at one point but that would have been a huge pain if I transferred the site to another domain.

 

Cheers

 

on another note,

Does anybody separate each page into subdirectories and then include an index file in each of these (I have seen that used before, but never saw the point)

 

I keep my style sheets in the same folder as my html files, is that wrong? should they be kept in /css ?

 

It's not a wrong as such but I think it just keeps it neater and invokes the idea of css more so (style separate from content)

Pretty much the same for me too.

I use

/css

/js

/images

/includes

 

but on larger sites I will also create folders for picture galleries etc, so that they are separate from images associated with page layout etc... eg

/gallery

/anothergallery

 

I just find it's easier to find everything this way.

I think this is a stupid qeustion... and it kinda fits here (me thinks) but how do you a get a web URL without the www's? eg nibor.co.uk?

I think this is a stupid qeustion... and it kinda fits here (me thinks) but how do you a get a web URL without the www's? eg nibor.co.uk?

not really sure what your asking, stop me if i'm wrong.

 

the www is a subdomain of your main domain name.

 

there domain name is setup through your DNS settings, you should add a A RECORD to create the www (is it a A RECORD or CNAME? someone can correct me)

 

Do you host you only server/ control DNS settings for you domains?

 

 

anyway, back to topic, i usually set it up as

 

css

images

includes

js

docs

(sometimes)pages - if i'm creating a templating system

 

 

very handy bit of script which let you setup your directories

 

<?php
// Set directories
if(DIRECTORY_SEPARATOR == '\\') {
	$fullpath = str_replace("\\", "/", __FILE__);
} else {
	$fullpath = __FILE__;
}

$breadcrumb = explode("/", $fullpath);
$filename = end($breadcrumb);
$temp = strlen(prev($breadcrumb))+1;

$directory['base']    = substr($fullpath, strlen($_SERVER['DOCUMENT_ROOT']), (-1 * strlen($filename) - $temp));
$directory['include'] = substr($fullpath, 0, (-1 * strlen($filename)));
$directory['image']   = $directory['base']."images/";
$directory['css']     = $directory['base']."css/";
$directory['script']  = $directory['base']."js/";

$temp = explode("/", substr($_SERVER['PHP_SELF'], strlen($directory['base'])));


?>

 

i'm currently looking into code igniter framework which setup the directories in a far bigger way, looks good:)

normally it goes like this:

 

images ...images go here -_-

style...css, js and anything else that might influence the style

includes...I don't put my header, menu and footer in here this is for other things that may need to be included

 

 

But it is subject to change and has done a lot :lol:

on another note,

Does anybody separate each page into subdirectories and then include an index file in each of these (I have seen that used before, but never saw the point)

It's not a wrong as such but I think it just keeps it neater and invokes the idea of css more so (style separate from content)

 

Yes quite often, and yes having an index page in each folder is very important. If you think about it a folder is like a sub section of you site so the index page will be that sections "home" page.

 

If you don't have an index page and someones types in http://www.mydomain.com/myfolder/ they will get a page not found or directory listing (depending how your server is set up).

I admit i'm lazy by nature so usually i just have an /images subfolder and the rest of the files in the home directory. If the website starting to get larger i usually make more subdirectories for include / css / js . Having every page in it's own directory definitly has advantages, but i usually don't bother.

 

Greetz R-J

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.