Why is it called index.html?

I was reading your HTML tutorials, and I noticed that you always name your files index.html. Is there any reason for that?

Yes, there is a reason. For example, if you have your page organized in certain folder and loaded in the server, then when you inquire the server like this:


will do one thing: It will go to that location and since you didn’t explicitly specify which page to load(what file is your main page), all servers will attempt to open an _index.htm_l file. Of course, this is more for convenience than anything else. Also this is the standard. Since most people never type the address of a site, I think it is ok to use index.html as your main cover page. If you don’t create an index.html page, then no big deal. You can always load your page like this:


and then, instead of having an index.html file in your root folder, you need to have a file called my-main-page.html file.

I hope this helps,



Yep, what @kfrajer said is correct.

When you visit a webpage like http://happycoding.io (without a file specified), it automatically looks for a file named index.html. You can see this by manually going to http://happycoding.io/index.html to see the same content.

So the reason I name my files index.html is just because by default, using this name allows you to use URLs that don’t include the filename.

But this is completely optional! If you wanted to name your file MyWebsite.html, that’s absolutely fine. You would just have to make sure you include the filename in every URL, because the server doesn’t know to look for a file named MyWebsite.html the way it looks for index.html.

This approach is pretty common if you want URLs like example.com/home.html and example.com/contact.html, for example.

Thanks for the explanations!

Why do I get an error if I go to http://forum.happycoding.io/index.html then? Shouldn’t that show the same thing as http://forum.happycoding.io?

That’s because there is no index.html file at that location. The homepage is loaded through other means. You can learn more about that side of things in the server tutorials.

(Technically the forum is not a Java server, but the ideas are the same.)

In other words: if you have a file named index.html, then you can usually leave the filename off. But just because the filename has been left off doesn’t always mean it’s coming from an index.html file, if that makes sense.