File organization

Hi
How do I organize the files/folders for the web site?
Placing all files in the root becomes un-managerial when the number of pages becomes too big.
Will it slow down the browser if I have files several levels from root?
Some talk about having an index page for each folder. Is it necessary and how can I have more than one index page?
Lastly, what do I do with the css files? Do I place a css file in each folder or just one in root with a global address.
The last option makes it impossible to preview the site.

Any ideas on this?
Thanks
Palmero

define “too big”

a few thousand doesn’t seem too big for me, i’ve got all my html and css and images in the root

what problems, exactly, are you trying to avoid?

I want to be able to find them later. They will be organised alphabetically, so related sites will be placed with some distance from each other. The same with images. I would prefer some kind of grouping, but it creates some other problems.

i’ve never seen anybody complain when they had to look up words like “aardvark” and “sloth” in the dictionary (words related by virtue of being animals) that they were “some distance” from each other

and being organized alphabetically, of course, is what makes the dictionary successful

have you ever seen a dictionary that’s organized into folders?

this is not what i meant when i asked “what problems, exactly

I tend to group my files based on what type of document they are… Images, Feeds, Scripts, Style.

As all of my HTML / PHP files rest in the root folder there isn’t a problem with relative linking (that and I have a nifty htaccess mechanism in place to ensure one wouldn’t occur on sub-paths, it doesn’t slow down the site having the files in folders, however it really depends what works best for your needs. :slight_smile:

I like to organize the content into logical sections, matching the site navigation.

Some talk about having an index page for each folder. Is it necessary and how can I have more than one index page?

You can (and should) have one index page per folder, even if it’s not used. (Otherwise people can view all the files in that folder, a bit like see-through clothing.)

Lastly, what do I do with the css files? Do I place a css file in each folder or just one in root with a global address. The last option makes it impossible to preview the site.

Huh? Keep your stylessheets in one folder, whether you use one or more. What do you mean by previewing the site? There should be no problem there.

Yes! All dictionaries are effectively organized into folders. A, B, C… That makes it easy to jump to the section you want. :wink:

with the exact same reasoning, i have all my stuff in the root AND it is easy to jump to the section i want

if i’m browsing the root directory all i have to do is start typing and vwalah – it jumps to the files that begin with that letter

so therefore there is no reason to use folders

:smiley: :smiley:

Fair enough. But that means using two hands, while I can get to the file I want just with one hand on the mouse! I guess I’m a bit anal about having things organized into groups. But I also prefer not to display file extensions, so having materials in folders gives neater urls. Also, if a page has lots of images or files associated with it, they can be stored nicely within that folder, and I don’t have to scroll past them unless I really need to see them.

Anyway, that’s just me… You’re a much more experienced web practitioner than I, so who am I to argue? :wink:

what is this mouse thing you speak of? :wink:

I’ve always had my files organised in this format:

  • The main root folder with index.php includes any other applicable pages.
  • an i folder for images
  • a css folder for… well figure it out
  • and a js folder for javascript files.

This is for a basic website. This could also include other folders for various things based on what the application of the website is.

Whatever you do try not to have multiple image folders. For example, some people like to have a different folder for each page (ex: “about us”) on their website, and in that folder they have an images folder. And they do this for the pages that have related content. From my experience this can become very confusing and results in duplicate images and the like. Especially if you are using the same image on multiple pages. Put everything in the root.

Example:

/root_folder
images_folder
stylesheets_folder
javascripts_folder
index.php
page1.php
page2.htm
page3.htm

I am a great believer in having a virtually empty root directory and numerous sub-directories. The idea being that it is very easy to change from an old version to a new version. This is accomplished with just editing a single line in the root index.php file.

This technique also means the site is only momentarily down while upgrading to a new version and also prevents the stupid “Under Construction” pages that I find very irritating especially since a site is always under construction otherwise it is obsolete.

This also works for when I upgrade to a newer version of any the framework software used. The site under construction can be thoroughly tested at my leisure before going live. I have bitter experience of upgrading to a the latest framework version and find that the live site no longer works as expected.

The root index.php file



<?php

  session_start();
  
	ini_set('display_errors', 'On');
	error_reporting(E_ALL | E_STRICT);

// header('Location: http://my_domain.com/ver_001/', 301); // original 

   header('Location: http://my_domain.com/ver_002'/, 301); // current 

// header('Location: http://my_domain.com/ver_003/', 301); // under construction 

   exit;

?>


Also because all the versions use the same graphics, etc I have a couple of common directories off the root for images, thumbs, etc

All CSS files are relevant to the particular version so each resides in the same version directory.

.

It’s a small, hand-held device, shaped somewhat like a mouse (hence the name) that is connected to the pc–traditionally by a wire, though commonly nowadays wirelessly. As you move the mouse around on your desktop, a cursor moves around the screen; and if you hover the cursor over certain buttons and whatnot, you can press the mouse and… :stuck_out_tongue:

I wasn’t a computer user in the days before mice, and navigation without one has always been a mystery I’ve meant to solve. Was at a client’s home today, and her wireless mouse died (battery flat), and try as I may, I couldn’t get anything to happen on screen without the mouse. Really would love to be able to do without it… at least in an emergency.

Thanks everybody
I think problem solved. As far as I understand the index for each directory must be:
./dir/index.html
and not
./dir/pagetitle/index.html
The last doesn’t seem to work. So I can’t have the page title in the filename for the index page?
My software doesn’t allow a trailing slash after html. Hope that’s ok. Though Safari will automatically complete the address (if known) including a slash, and get a 404.

That’s right. mysite.com/pagetitle/index.html is what you do, and the url will be mysite.com/pagetitle/ . That’s a lot neater, and makes for much nicer printed urls.

So the page file doesn’t have the title in it, but that’s only a pain when you have lots of index.html files open in your text editor… which doesn’t bother me.

ralph.m

and the url will be mysite.com/pagetitle/

So the page file doesn’t have the title in it

Now you are confusing me!! Isn’t it contradictory? And what happened to the directory?
If I upload this:
mysite.com/dir/pagetitle/index.html
the last slash is replaced with a colon (:)!

mysite.com/pagetitle/index.html

mysite.com = domain name
pagetitle = directory (or folder)
index.html = page file

So, you create a folder (directory) in your root folder, called pagetitle. In that directory is a file called index.html (or index.php, or whatever).

If you want to tell people about your page (that is, give them a link–say in a printed publication), the path you give them to the file is:
mysite.com/pagetitle/

You don’t need to mention the index.html bit at all, because if you just call on the directory (“pagetitle”) the server displays the index file by default.

I’m not sure what you mean by “the last slash is replaced by a colon”. Under what circumstances?

Depends on the content of your site. Organise it according to content or by navigation then have an images, css, javascript folder at the top.

Here are the details: If I upload this:
mysite.com/adm/privacy/index.html
where
adm=directory with administrative files
privacy=privacy policy page

the file manager (cPanel) changes it to:
mysite.com/adm/privacy:index.html

which works in a browser, but is of course inappropriate.

If I name the privacy page index and upload this:
mysite.com/adm/index.html
it works and can be found with both these addresses:
mysite.com/adm/
mysite.com/adm/index.html
but then I don’t have the title of the page (Privacy Policy) in the link.

Can a “cPanel” not accept more than one “/index”?

NO!

In the root folder, you have another folder/directory called /adm/.
Now, create a new folder in /adm/ called /privacy/.
In the /privacy/ folder, place a file called index.html. In index.html put the page content.
Upload, and navigate to mysite.com/adm/privacy/
The page will show up perfectly. Your mistake is not to create a folder called /privacy/ within the /adm/ folder.