Host a website for free with GitHub Pages
This site is hosted by GitHub, and it doesn’t cost anything. The pages are plain files in a folder called docs/ in one of my repos. A free GitHub feature called Pages serves that folder as a website. The only part I pay for is the domain name. You can set up the same thing in about 15 minutes. Adding your own domain takes another 20 or so, and most of that is waiting.
Make a repo
First, sign in to GitHub, or make an account if you don’t have one (it’s free). Then make a repo. A repo, short for repository, is a project folder that GitHub stores along with a history of every change to it.
Click the plus sign in the top right corner, then New repository. Name it something like mysite and make sure it’s set to Public. Free accounts can only use Pages with public repos, which is fine for a website. Leave the README option and everything else turned off, and click Create repository.
Since the repo is empty, GitHub shows you a page of setup commands. You run them in a terminal on your computer, so you’ll need git installed. The first two lines below make a folder and move into it. The rest is GitHub’s block from the section labeled “…or create a new repository on the command line.” Copy it from that page so your username and repo name are already filled in.
mkdir mysite
cd mysite
echo "# mysite" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/YOUR-USERNAME/mysite.git
git push -u origin main
The git remote add line connects your folder to the repo on GitHub, and git push sends your files up to it. The first time you push, git may ask for a password. It wants a token here, not your GitHub password. The easiest way around that is to install GitHub’s command line tool and run gh auth login once. It signs you in through your browser and takes care of it from then on.
Add a home page
Inside mysite, make a folder called docs, and in it a file called index.html. When someone visits an address that ends in a folder, the server sends them that folder’s index.html. So this file is your home page. Paste this into it and swap in your own name and links:
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Your Name</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css">
<main style="max-width: 40rem; padding-top: 12vh">
<hgroup><h1>Your Name</h1><p>This is my website.</p></hgroup>
<article><h3><a href="https://github.com/you/one">Project one</a></h3>What it does, in one line.</article>
<article><h3><a href="https://github.com/you/two">Project two</a></h3>What it does, in one line.</article>
<p><a href="mailto:you@example.com">Email</a> · <a href="https://github.com/you">GitHub</a> · <a href="https://www.linkedin.com/in/you">LinkedIn</a></p>
</main>
That’s the whole site. The <link> line pulls in Pico CSS, a free stylesheet hosted on a CDN called jsDelivr. A CDN is a network of servers that hands out common files, so you don’t have to host them yourself. Pico is what’s called a classless stylesheet. It styles plain HTML tags on its own, so you don’t write any CSS.
Each <article> becomes a card, and the line under your name turns gray. Everything switches to dark colors for people whose computers are set to dark mode. The style bit on <main> keeps the column narrow and adds some room at the top. It looks like this on a laptop, and it shrinks to fit on a phone.

Pico comes in 20 colors. For green, change pico.classless.min.css in the link to pico.classless.jade.min.css. Simple.css and Water.css work the same way if you want a different look.
Then send it to GitHub:
git add docs
git commit -m "Add home page"
git push
git add tells git to include the new folder. git commit saves a snapshot of it with a short note, and git push sends that snapshot to GitHub.
If you’d rather not use a terminal at all, you can skip both blocks and do this on GitHub’s website. Right after you create the repo, click the link to create a new file and name it docs/index.html. Typing the slash makes the folder. Paste in the HTML and click Commit changes. That works fine for one page. Once you’re editing a bunch of files, the terminal is faster.
Turn on Pages
Back on GitHub, go to your repo and click Settings along the top, then Pages in the left sidebar. Under “Build and deployment,” set Source to “Deploy from a branch.” Under Branch, pick main, change the folder from / (root) to /docs, and click Save.
That’s it. After a minute or so, the top of the Pages settings will say your site is live, with a link to YOUR-USERNAME.github.io/mysite. You can watch the deploy run in the repo’s Actions tab if you’re curious. From now on, every push that changes docs/ updates the site the same way.
If you name the repo YOUR-USERNAME.github.io instead, the site lives at that address with nothing after it. Each account gets one of those.
The site can get as fancy as you want from here. Pages serves whatever is in docs/, so any pile of HTML, CSS, and JavaScript works. This site is built with Hugo, a program that turns a folder of Markdown files into web pages. I commit its output to docs/, and Pages does the rest.
If you’d rather not commit built files, set Source to “GitHub Actions” instead. Actions is GitHub’s way of running scripts on its own servers when something happens in a repo. With that setting, GitHub runs your build every time you push and publishes the result. It has starter setups for Hugo, Jekyll, plain HTML, and a bunch of others.
Use your own domain
A github.io address works, but your own domain is easier to remember and looks better on a resume. You can buy one from a registrar like Namecheap or Cloudflare. A .com runs about $10 to $20 a year, which is a dollar or two a month. Connecting it to your site takes three steps.
The first step happens on GitHub. On the same Pages settings page, type your domain (like yourname.com) under Custom domain and click Save. GitHub adds a file called CNAME to your docs folder with your domain on one line. That file is how GitHub knows which site to show when someone visits your domain. GitHub commits it for you, so run git pull before your next push. Git will refuse the push until you do.
The second step happens at your registrar, and it’s all DNS records. DNS is the internet’s address book. It tells browsers which server to ask for a given domain. You need five records. Four are A records, which point a domain at a numeric address. The fifth is a CNAME record, which points one name at another name.
Type Host Value
A @ 185.199.108.153
A @ 185.199.109.153
A @ 185.199.110.153
A @ 185.199.111.153
CNAME www YOUR-USERNAME.github.io
The @ stands for the bare domain, yourname.com. The www record covers www.yourname.com. Its value is just your username plus .github.io, with no repo name on the end. With both in place, GitHub redirects one to the other, so either address works. GitHub’s custom domain docs also list four AAAA records for IPv6, the newer and longer style of address. They’re optional.
On Namecheap, go to Domain List and click Manage next to your domain. Open the Advanced DNS tab. New domains come with two parking records: a CNAME for www that points to Namecheap’s parking page, and a URL Redirect for @. Delete both. Then click Add New Record once for each line above, and leave TTL on Automatic.
On Cloudflare, pick your domain and go to DNS, then Records. Click Add record for each line above. Cloudflare sets new records to Proxied, which shows as an orange cloud. Click the toggle so the cloud turns gray and says DNS only. GitHub needs your domain to point straight at its servers before it will verify it, and Cloudflare’s proxy sits in between.
The third step is waiting. GitHub checks your DNS records on its own, and that usually takes 5 to 20 minutes. Sometimes it takes an hour. The Pages settings will say “DNS check in progress” the whole time. That’s normal, so don’t start changing records. Once the check passes, GitHub gets a free certificate for your domain so it can use HTTPS. HTTPS is the encrypted kind of web connection, the one with the lock icon in the address bar. When the Enforce HTTPS box stops being grayed out, check it. And you’re done.