Index.html files in directories.. Why you should use them.

Posted by Lindsayanng on February 10th, 2009

If you are new to web design, which most of you are, you might not know the power of the INDEX page.

The index page is the page that a browser will default to when it opens a directory (remember, directory and folder are interchangeable in the web world). This is the reason why your “home page” should always be named “index” and not “home” or “mywebsite.” When someone browses to your website, they we basically looking at your public_html directory, and in that directory it will look for the index page to show the visitor… Then the visitor will click on links in your site and those links will take them away from the index page..

But did you know that a page named index can do more than just be your home page??

One of the most common things that I see when looking at a “newbie’s” website is that they have urls that look like this:
mywebsite.com/flowers/flowers.html
This site has this issue:

This is because they were smart and wanted to organize all of their content into directories, so they put all of the images and content for the “flowers” page in a folder called flowers, and then put the flowers page in there too. Just to keep it all organized. This is actually the BEST practice for building websites. (if you want to learn more about content organization click here).

There are some serious pitfalls of not using index files in your directories as well. When you have a directory, but no index file, people can type in your domain and directory, they will be shown a list of files that exist in that directory. When you have an index, they will always be shown a page. The reason this is bad is, well, you are showing people your “behind the scenes” stuff. This can be an open invite to hackers who will probe around until they find a file that they can use.. It is not worth it..

It also doesn’t look nearly as pretty to see “yourdomain.com/flowers/flowers.html” :)

To get a url to look nice and clean while also getting your content nicely organized, you simply name the file that is inside of your directory index.html. It will work the same way as your home page, the browser goes to your directory, and instantly defaults to an index.html page. It’s as simple as that.. No secrete trick really, just repeating what you already knew when you started..

So that is it. If you have lots of folders, you will have lots of files called index.html, but they will be nicely organized within the folder that contains all of the other content for your website!

So get organized BEFORE you publish, because once you are published, and you start moving things around, you will get the search engines all sorts of confused, and you want to stay on their good side.

VN:F [1.9.7_1111]
Rating: 0 (from 0 votes)

Want to know who is offering this awesome content? Here it is! Someone who is relatively new to web design. I am new enough to still remember how absolutely frustrating it was to try and get anything done in this field, but have also been around long enough to be able to help those that are where I was a year ago. Aside from web design, I run the office of my dad's engineering business, and do book keeping by trade. I love my pets.. All 6 cats, 1 peg legged dogs, and 1 hedgehog. LOVE THEM!! Oh yea, and my husband. He lets me chase my dreams and I let him do the same. We are happy people because of it. Read more from this author


Tags: , , , , , , , , , ,

Leave a Reply

Improve the web with Nofollow Reciprocity.