How to turn an HTML file into a website

The file is already the website. It is missing an address, and four things that only matter once somebody else opens it.

A file that opens in a browser is already a page. Making it a website means giving it an address and fixing the four things that only break once somebody else opens it.

A local file open in a browser beside the same page at a public address on a phone.
A local file open in a browser beside the same page at a public address on a phone.

This guide covers the four, and what a domain is for.

One: paths

The most common difference between working locally and working published.

<link rel="stylesheet" href="/style.css">   <!-- fails under a subfolder -->
<link rel="stylesheet" href="style.css">    <!-- works -->

A leading slash means from the top of the domain. Locally the top is your folder, so it works. Published under any subfolder, it points somewhere your files are not.

Case matters too. Most desktop machines treat Logo.png and logo.png as the same file; servers generally do not. Rename everything lowercase before publishing and the problem disappears.

Two: the head

Three lines that decide how the page behaves for everyone who is not you.

<title>What this page is</title>
<meta name="description" content="One sentence for a search result.">
<meta name="viewport" content="width=device-width, initial-scale=1">

The title is what appears in the browser tab, in search results and in a shared link. Without it the page is named after the file.

The description is the line under the title in a search result, and it is what a messaging app shows when the link is pasted.

The viewport tag is what makes a phone render the page at phone width instead of pretending to be a desktop and zooming out. Without it, a page that is perfectly responsive still looks tiny on a phone.

Missing Symptom
Title Tab and search result show a file name
Description Shared links look bare
Viewport tag Page renders tiny on a phone
Relative paths No styling, missing images

Three: check it on a phone

The page was built on the machine it looks correct on. That proves very little.

Open the published address on an actual phone. Look for horizontal scrolling, text too small to read, and anything needing a hover that now does nothing.

Those three are the usual set, and all of them are invisible from a desktop.

Four: one page is enough

A single page is a complete website when it says one thing.

Adding an about page, a contact page and a blog because websites are supposed to have them produces a site with four pages and nothing on three of them. That is worse than one good page.

Add pages when there is content that genuinely does not belong on the first one.

A page head showing title, description and viewport tags.
A page head showing title, description and viewport tags.

The domain

The page works without one. The address is what does not survive without one.

An address on a hosting provider's domain belongs to the provider. Move, or they close, and every link you published breaks: the ones in messages, in other people's pages, in printed material, in search results.

Your own domain means moving is a change of where it points. Nothing breaks.

If you expect to still be using these links in a year, get one before publishing the address rather than after.

Closely related: Free HTML file hosting, compared, and HTML to link for the adjacent problem.

.html file sitting on your disk drop Hosted page served over https get link Shareable URL opens on any device
A file on disk becoming an address that opens on any device.

Put it at an address

Name it index.html, make every path relative and lowercase, add a title, description and viewport tag, check it on a phone, and put your own domain in front of it.

Then the file that worked on your machine works for everyone.

Questions people ask

Is my file already a website?

The content is. What is missing is an address, so anyone else can reach it. That is the whole difference between a file and a site.

Why does it look different once published?

Usually paths. A server is strict about leading slashes and about case, and your machine is not. Anything the page loads from elsewhere is where the difference appears.

Do I need more than one page?

No. A single page is a complete website when it says one thing. Adding pages because sites are supposed to have them makes it worse rather than better.

What do I need before sharing the address?

A title, a description, a viewport setting for phones, and every path working. Those four cover almost everything that goes wrong.

Does it need a domain?

Not to work. It needs one if you want the address to survive changing where it is hosted, which matters as soon as you have published the link anywhere.

Keep reading