Understanding the Index.html Page on a Website

How to Create Default Web Pages

ipad next to breakfast
Yuri_Arcurs DigitalVision/Getty Image/

One of the very first things you will learn as you begin dipping your toes into the waters of website design is how to save your documents as web pages. Many tutorials and articles about getting started with web design will instruct you to "save" your initial HTML document with the file name "index.html". If you think that seems like a strange choice for the page name, you're not alone in that opinion.

So why is this done? Let's take a look at the meaning behind this particular naming convention which is, indeed, an industry-wide standard.

A Basic Explanation 

The index.html page is the most common name used for the default page shown on a website if no other page is specified when a visitor requests the site. In other words, index.html is the name used for the homepage of the website.

A More Detailed Explanation

Websites are built inside of directories on a web server. Just like you have folders on your computer that you save files into, you do the same with a web server by adding your website files, including HTML pages, images, scripts, CSS, and more - basically all the individual building blocks of your site. You can name directories based on the content they will contain. For example, websites commonly include a directory labeled "images" which contains all the graphic files used for the website.

For your website, you will need to save each webpage as a separate file. For example, your "About Us" page may be saved as "about.html" and your "Contact Us" page may be "contact.html". Your site will be comprised of these .html documents.

Sometimes when someone visits the website, they do so without specifying one of these specific files in the address that they use for the URL.

For example:


That URL includes the domain, but there is no specific file listed. This is what happens whenever anyone goes to a URL specified in an advertisement or on a business card. Those ads/materials will likely advertise the basic URL of the website, which means that anyone who chooses to use that URL will basically go to the homepage of the site since they have not requested any specific page.

Now, even though there is no page listed in the URL request they make to the server,  that web server still needs to deliver a page for this request so that the browser has something to display. The file that will be delivered is the default page for that directory. Basically, if no file is requested, the server knows which one to serve up by default. On most web servers, the default page in a directory is named index.html.

In essence, when you go to a URL and specify a specific file, that is what the server will deliver. If you do not specify a file name, the server looks for a default file and displays that automatically - almost as if you had typed in that file name in the URL. Below is what is actually shown if you went to the previously shown URL.

Other Default Page Names

Besides index.html, there are other default page names that some sites use, including:

  • index.htm
  • default.htm or default.html
  • home.htm or home.html

The reality is that a web server can be configured to recognize any file you want as the default for that site. That being the case, it's still a good idea to stick with index.html or index.htm because it is immediately recognized on most servers without any additional configuration needed. While default.htm is sometimes used on Windows servers, using index.html all but ensures that no matter where you choose to host your site, including if you choose to move hosting providers in the future, your default homepage will still be recognized and properly displayed. 

You Should Have an index.html Page in All Your Directories

Whenever you have a directory on your website, it is a best practice to have a corresponding index.html page. This allows your readers to see a page when they come to that directory without typing a file name in the URL, preventing them from seeing a 404 Page Not Found error.

Even if you do not plan to display content on the index pages of select directories with any actual page links, having the file in place is a smart user experience move, as well as a security feature.

Using a Default File Name Like index.html is a Security Feature as Well

Most web servers start out with the directory structure visible when someone comes to a directory without a default file. This shows them information about the website that would otherwise be hidden, such as directories and other files in that folder. This can be helpful during a site's development, but once a site is live, allowing for directory viewing can be a security vulnerability that you will want to avoid.

If you don't put in an index.html file in a directory, by default most web servers will display a file listing of all the files in that directory. While this can be disabled at the server level, it means that you need to involve the server admin in order to make it work.  If you are pressed for time and want to control this on your own, an easy workaround is to simply write a default web page and name it index.html. Uploading that file to your directory will help close that potential security hole. Additionally, it is also a good idea to also contact your hosting provider and ask for directory viewing to be disabled. 

Sites That Do Not Use .HTML Files

Some websites, like those that are powered by a content management system or ones that use more robust programming languages like PHP or ASP, may not use .html pages in their structure. For these sites, you still want to ensure that a default page is specified, and for select directories in that site, having an index.html (or index.php, index.asp, etc.) page is still desirable for the reasons described above.

Original article by Jennifer Krynin. Edited by Jeremy Girard on 7/5/17