How to create a free website at username.github.io?
You can put a website on the internet for free using
GitHub Pages. GitHub is a website where people store and
share code; GitHub Pages is a free service that turns one of your code
folders into a real website. The address of the website is
username.github.io, where username is
the name you choose when you sign up for GitHub. No credit card is needed
and there is no monthly fee.
This note walks through the whole process, from opening a GitHub account to seeing your first page online, using only the GitHub website in your browser — no extra software required.
Watch the walkthrough
Open in Google Drive (no account needed).
What you need before you start
- An email address you can check right away (GitHub will send you a verification code).
- A username you like — it will become part of your
website address, so choose carefully. GitHub usernames may only contain
letters, numbers, and hyphens (
-); no underscores or spaces.
Step 1: Sign up for a GitHub account
Go to github.com and click Sign up. GitHub asks you to enter:
- Your email address.
- A password.
- A username. This is the most important choice, because
it becomes your website address. If you choose
pongyuenlam, your website will bepongyuenlam.github.io.
Click Create account.
Step 2: Verify your email
GitHub sends a short numeric code to your email address. Enter that code on the GitHub page to prove you own the email. After that, you can sign in to your new account.
Step 3: Create a repository named username.github.io
A repository is GitHub’s word for a project folder.
For a personal website, the repository must have a very specific name: it
must be exactly your GitHub username followed by
.github.io.
On GitHub, click your profile picture and choose New repository. In the Repository name box, type:
username.github.io
Replace username with your actual GitHub username. For
example, if your username is pongyuenlam, the repository name
must be pongyuenlam.github.io. If the name does not match your
username exactly, the free website address will not work.
Leave the other settings as they are and click Create repository.
Step 4: Create the file index.html
A website is made of files. The first page that visitors see is always
called index.html. On your new repository page, click
creating a new file.
In the box that asks for the file name, type exactly:
index.html
Then, in the large editing area below, type a simple page. Here is a small example you can copy and change:
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
</head>
<body>
<h1>Hello, world!</h1>
<p>This is my first website on GitHub Pages.</p>
</body>
</html>
Step 5: Commit (save) the file
At the bottom of the page, click Commit changes. GitHub asks you to confirm the commit; click Commit changes again. A commit is GitHub’s word for saving a version of your file.
Step 6: Wait and view your website
GitHub needs a short time to publish your page. Open a new browser tab and go to:
https://username.github.io
Again, replace username with your actual username. It
usually takes about one to two minutes for the page to
appear. If you see an error at first, wait a little longer and refresh the
page.
Editing your website later
To change your page, go back to your repository, click the
index.html file, then click the pencil icon
(Edit this file). Make your changes, scroll to the bottom,
and click Commit changes twice. Wait about one to two
minutes, refresh username.github.io, and your updated page
will appear. To refresh, press Cmd + R on a Mac or
Ctrl + R on Windows, or click the circular refresh icon
in the browser’s address bar.
What you can do next
- Add more pages. Create more
.htmlfiles in the same repository, for exampleabout.html, and link to them fromindex.html. - Add pictures. Upload image files to the repository and
show them on your pages with an
<img>tag. - Use a pre-made design. Search for “GitHub Pages themes” to make your site look more polished without writing all the styling yourself.
Limitations
- The repository name must be
username.github.io. If it is different, GitHub will not publish the site at that address. - It takes one to two minutes after each commit for the live site to update. If your change does not show up, wait and refresh.
- GitHub Pages is meant for static sites — pages
made of HTML, CSS, and images. It cannot run a database or server-side
programs on its own. If you already have a website that uses a database
or server-side programs, you can simply add a link to it on a page of
username.github.io.
Further reading
- GitHub Pages — the official product page and quick-start guide.
- Creating a GitHub Pages site — GitHub’s official documentation.
- Signing up for a new GitHub account — official help for creating an account.
- How to get a Google tag to understand the traffic to your website? — add a free Google Analytics tag to your new GitHub Pages site to see how many people visit it.