Understanding the Index.html Page on a Website

How to create default web pages

One of the very first things you 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. Let's take a look at the meaning behind this particular naming convention which is, indeed, an industry-wide standard.

Person browsing the Index page of /acme
Derek Abella / Lifewire

Default Homepage

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.

Site Architecture and Index.html

Websites are built inside of directories on a web server. For your website, you must 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:

http://www.lifewire.com

Even though there is no page listed in the URL request made 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.

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 change hosting providers in the future, your default homepage will still be recognized and 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. 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 view shows them information about the website that would otherwise be hidden, such as directories and other files in that folder. This transparency can be helpful during a site's development, but after a site is live, allowing for directory viewing can be a security vulnerability.

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 behavior can be disabled at the server level, it means that you need to involve the server admin in order to make it work.

IIS installations have directory browsing disabled by default. If the default document is not found and both default document and directory browsing is disabled, the user will get a 404 error.

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.

Format
mla apa chicago
Your Citation
Kyrnin, Jennifer. "Understanding the Index.html Page on a Website." ThoughtCo, Sep. 30, 2021, thoughtco.com/index-html-page-3466505. Kyrnin, Jennifer. (2021, September 30). Understanding the Index.html Page on a Website. Retrieved from https://www.thoughtco.com/index-html-page-3466505 Kyrnin, Jennifer. "Understanding the Index.html Page on a Website." ThoughtCo. https://www.thoughtco.com/index-html-page-3466505 (accessed March 19, 2024).