You do not need a hosting plan or a server. Put one HTML file in a public GitHub repository, turn on GitHub Pages, and the page is on the internet. The free address looks like yourname.github.io. If you want yourname.com, you buy the name and point it at the same page.
What you pay for
Hosting, HTTPS, and the github.io address are free. The domain name is optional. Skip it and the free address still works. This setup serves files only: HTML, CSS, and JavaScript. There is no database and nowhere to hide a password.
Make the page
01 Make a GitHub account
Go to github.com and sign up. The username becomes part of your free address, so pick one you can live with. You can do every step below in the browser. You do not need to install Git.
02 Create the repository
Click New repository. The name has to be your username, then .github.io, and nothing else. If the username is ada, the repository is ada.github.io. Set it to Public. You can leave "Add a README" off.
GitHub only serves a personal site from a repository with that exact name. A typo or an extra word means the site will not show up at the root address. On the free plan the repository has to stay public, or Pages will not publish it.
03 Add index.html
On the repository page, click Add file, then Create new file. Name it index.html. Paste this, then commit it to the main branch.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Your Name</title>
</head>
<body>
<h1>Hello.</h1>
<p>This is my website.</p>
</body>
</html>That file is the whole website. The name has to be exactly index.html, in the root of the repository, not inside a folder.
04 Turn on Pages
Open Settings, then Pages. Under Build and deployment, set Source to Deploy from a branch. Set the branch to main and the folder to / (root). Save.
05 Open it
Wait a few minutes, then visit https://yourusername.github.io. The first publish can take up to ten minutes. GitHub builds the site from the files on main and serves index.html as the homepage. The account that made the commit needs a verified email address, or the build will not run.
Use your own address
Hosting stays free. You are paying a registrar for the name, usually about $10 to $15 a year, and then telling the internet that the name belongs to the page you just published.
06 Buy a domain
Buy yourname.com from a registrar. Cloudflare, Porkbun, and Namecheap are all fine. Decline the website-builder and hosting add-ons. You already have hosting.
07 Claim it on GitHub
Verify the domain before you point it anywhere. Open your account settings from your profile photo, not the repository settings. Go to Pages, choose Add a domain, and enter yourname.com. GitHub shows you a TXT record. Add that record at your registrar, then click Verify. That stops someone else from attaching your domain to their site.
Then open the repository's Settings, then Pages. Under Custom domain, enter yourname.com and save. GitHub adds a file named CNAME to the repository. Leave that file alone.
08 Point the domain at GitHub
At the registrar, open DNS for the domain. Delete any parking-page records already set on the root. Then add these. The host @ means the bare domain, yourname.com.
| Host | Type | Value |
|---|---|---|
@ | A | 185.199.108.153 |
@ | A | 185.199.109.153 |
@ | A | 185.199.110.153 |
@ | A | 185.199.111.153 |
www | CNAME | yourusername.github.io |
The CNAME value is your GitHub Pages host. No https://, and no path on the end. Use your real username in place of yourusername.
If you want blog.yourname.com instead of the root, skip the A records. Add one CNAME for blog pointing at yourusername.github.io, and type blog.yourname.com in the custom domain box.
09 Turn on HTTPS
DNS can take a few minutes, and sometimes a day. When the Pages settings stop warning about DNS, check Enforce HTTPS. GitHub requests the certificate for you. Leave the box checked.
yourname.com and www.yourname.com both reach the site. GitHub redirects one to the other, using whichever name you saved as the custom domain.
Change the page
Edit index.html on GitHub and commit. The live site updates after the next build, usually within a few minutes. Add a style.css or an image the same way, and link it from the HTML with a relative path.
<link rel="stylesheet" href="style.css">When it breaks
- The repository name has to match the username exactly, plus
.github.io. Index.HTMLis a different file. The homepage file isindex.html.- A 404 after ten minutes usually means the file is in a folder, Pages is pointed at the wrong branch, or the publishing account's email is not verified.
- Extra DNS records are the usual reason HTTPS never turns on. Remove old A records, URL redirects, and parking CNAMEs. If the domain is on Cloudflare, set these records to DNS only, the grey cloud, until the certificate appears.
- Do not add a wildcard record like
*.yourname.com. It can let someone else serve a site on a subdomain you did not mean to publish. - GitHub Pages will not run PHP, Python, or a database. A page that needs a login or a secret needs a different host.
That is the whole setup. One public repository, one HTML file, and an address you can send to people.