Static Sites & Deployment

index.html

Definition

index.html is a naming convention, not a special format — the file itself is ordinary HTML. What makes it special is that servers are configured to look for it whenever a request ends at a directory. Ask for https://example.com/ and the server serves the index.html sitting at the top of the folder; ask for /pricing/ and it serves pricing/index.html. This is called the directory index, and it is why URLs can end in a tidy slash instead of naming a file. Some servers accept other names in the same role, such as index.htm or default.html on older Windows hosts, but index.html is the one every host understands. It is also the entry point browsers and crawlers assume when they are given nothing more specific than a domain.

Why It Matters

Get this file wrong and the site has no front door, however good the rest of it is. A folder with no index.html produces one of two unhelpful things: a directory listing, which exposes every file name you uploaded to anyone who visits, or a 404, which makes a site that is entirely present look entirely missing. Both are common right after a first upload, and both are fixed by renaming one file. The listing case is the worse of the two, because draft PDFs, old exports and half-finished pages are then discoverable by anyone who guesses the address. Modern static hosts default to returning 404 rather than listing, which is safer but hides the actual cause.

How It Works

A request for a path with no filename makes the server check for a directory index inside that folder. If index.html exists, it is returned with a 200 status and Content-Type of text/html, and the URL in the address bar stays as the folder path. If it does not exist, the server does one of three things depending on its configuration: generate an HTML listing of the folder's contents, return 404 Not Found, or serve a custom 404 page you supplied. Filenames are matched case-sensitively on Linux hosts, so Index.html and index.HTML are simply different files and neither will be found. Requests that name a file directly, such as /about.html, skip this lookup entirely — the index rule only applies when the path ends at a directory.

Real-World Example

Someone exports a site from a design tool and uploads a folder whose home page is called home.html. On 99helpers the address portfolio-rk.99helpers.site answers with a 404, even though all sixteen files are plainly there under their own names. Renaming home.html to index.html and re-uploading fixes it in one step, and the same rule then gives them /work/ and /contact/ for free once each of those folders has its own index.html. Nothing about the page's content changed — only which file the server was allowed to treat as the default.

Common Mistakes

  • Naming the home page home.html, main.html or default.html — the server has no way to guess which of your files is meant to be the front door
  • Letting an editor save the file as index.html.txt — the real extension is .txt, so the browser shows the markup as plain text instead of rendering it
  • Giving sub-folders no index of their own — /blog/ then 404s or lists its contents while /blog/post-one.html works perfectly

Related Terms

Put a file online in seconds

Drop in a document, an image, a page or a whole static website and share the link — free, with no build step and no server to set up.

Host a file free →