Directory Tips for Web Designers
Welcome to my blog, please feel free to subscribe to my RSS feed, join me on Twitter or leave a comment.
Building a great website is about a lot more than putting together a bunch of text or graphics on a page, it’s critical that a website be manageable and expandable if you want it to work properly in the future. With that in mind, here are some basic tips for new web designers that a lot of books seem to overlook but I feel are critical.
Directory Structure
First off, organize your files effectively. It may seem silly but there’s nothing worse than having to go back and find a file in a months time and it only take a few minutes to do it right the first time. Building a proper directory structure is simple, first lets start with the root folder (that’s the main directory of your website) and add a few new folders:
- css – cascading style sheets directory
- images – used for all the images on our site
- includes – common files that are loaded by multiple pages
- js – the javascripts for our site
- media – a directory for rich media
Now these new folders will store all of our future files and make the job of locating the related content much easier. Remember, we always want to lowercase our directory names to make it easier to remember.
File Names
A common mistake in naming files is to use MiXed CaSe or Capital Case. This works great for labelling filenames on your personal computer but many web servers are case sensitive meaning two files may have the same name as long as they have a different mix of upper and lower case characters. For example, Index.php and index.php are considered separate files on standard web servers.In addition to the quirks of web servers, we also want to avoid using mixed or upper case names for our users. That way a user only has to remember the path to your specific page and not the case structure of your web naming conventions. If you do have to separate a filename into recognizable sections, I prefer to use an underscore (_) or a dash (-) to do it such as contact_form.php or conact-form.php which allows users to easily see and dictate the spelling to others.
File Extensions
There are few things more frustrating than trying to remember the proper syntax of a filename when you’re coding or looking for a specific file. Adding to the confusion is file extensions which often vary from one web server to another. To simplify the process, I strongly recommend always using the .php (for Linux servers) or .asp (for Windows servers) for all your HTML and scripting files. The additional server time needed to load these pages will be minimal and it allows you the easy of standardizing the extensions for your development speed.
Hiding Directories
Sometimes we create web directories that we don’t want the outside world to see. For example, there is no purpose in allowing users access to the /root/images/ directory but we still want people to be able to view the images stored there, so we need an easy way to limit peoples access to that particular directory. Without getting into complex .htaccess files, one of the easiest means to accomplish this goal is the create a new index.php file and upload it to the directory, this will cause people to see a blank page upon reaching the page.If you want something slightly more interesting, you can bounce people back to the directory above the restricted path by including the code <?php header(“location:../”);?> in the index.php file. This little piece of code will force the browser to refresh immediately to the directory above or in our example, if placed in the /root/index/ directory it will force the user back to the /root/ directory.





