How to Make a GitHub Website- Complete Tutorial
What You're Getting Into
GitHub Pages is free web hosting. That's the bottom line. You get a website up and running without paying a dime for hosting. The catch? Your content lives in a public repository (unless you pay for GitHub Pro), and you get limited customization options compared to traditional hosting.
This guide cuts through the noise. By the end, you'll have a live website running on github.io.
Why Use GitHub Pages?
Here's the deal:
- It's free — no hosting costs, no catches for basic usage
- Version control — every change is tracked, and you can roll back mistakes
- Custom domains work — connect your own domain if you want
- Fast enough — served from a global CDN
Perfect for portfolios, documentation, project pages, or personal blogs. Not ideal for e-commerce or anything requiring server-side processing.
What You Need Before Starting
- A GitHub account (free tier works fine)
- A computer with internet access
- Basic HTML knowledge helps, but isn't strictly required
- 10-15 minutes of uninterrupted time
Step 1: Create Your GitHub Account
Head to github.com and sign up. Pick a username you'll be okay with because this becomes part of your URL: yourusername.github.io.
Choose your username carefully. This isn't easily changed later.
Step 2: Create a New Repository
After logging in:
- Click the + button in the top-right corner
- Select "New repository"
- Name it exactly: yourusername.github.io (replace "yourusername" with your actual GitHub username)
- Set it to Public (required for free hosting)
- Check "Add a README file"
- Click "Create repository"
That's it. Your repository exists. Now you need to put files in it.
Step 3: Create Your First File
You have two options here. I'll show you both.
Option A: Through the GitHub Web Interface
This works if you're not comfortable with command line tools.
- Inside your new repository, click Add file → Create new file
- Name it index.html
- Paste this basic HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Site</title>
</head>
<body>
<h1>Hello, World</h1>
<p>My site is live!</p>
</body>
</html>
- Scroll down, add a commit message like "Add index.html"
- Click Commit new file
Option B: Using Git on Your Computer
If you're comfortable with the terminal, this approach scales better for larger projects.
# Clone the repository to your computer
git clone https://github.com/yourusername/yourusername.github.io.git
# Navigate into the folder
cd yourusername.github.io
# Create your HTML file
echo "<!DOCTYPE html>
<html>
<body>
<h1>Hello, World</h1>
</body>
</html>" > index.html
# Add, commit, and push
git add index.html
git commit -m "Add index.html"
git push origin main
Use this method if you plan to update your site regularly. It's faster once set up.
Step 4: Enable GitHub Pages
Here's where people get stuck. GitHub Pages doesn't auto-enable.
- Go to your repository's Settings tab
- Scroll down to Pages (usually in the left sidebar under "Code and automation")
- Under "Source", click the dropdown and select Deploy from a branch
- Next dropdown: select main
- Next dropdown: select / (root)
- Click Save
Wait 1-2 minutes. Your site goes live at https://yourusername.github.io
Step 5: Verify It's Working
Open a new browser tab. Type your URL. You should see your HTML rendered as a webpage.
If you see a 404 error, give it more time. GitHub's deployment can take up to 5 minutes sometimes.
Adding More Pages
Create additional HTML files for more pages:
- about.html — your about page
- projects.html — showcase your work
- contact.html — how to reach you
Link them together in your navigation:
<nav>
<a href="index.html">Home</a>
<a href="about.html">About</a>
<a href="projects.html">Projects</a>
</nav>
Customizing With CSS
Plain HTML is ugly. Add a stylesheet.
- Create a file named style.css
- Add your CSS rules:
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #f5f5f5;
}
h1 {
color: #333;
}
nav a {
margin-right: 15px;
text-decoration: none;
color: #0066cc;
}
- Link it in your HTML by adding this to your
<head>:
<link rel="stylesheet" href="style.css">
Using a Custom Domain
Want your site at yourdomain.com instead of github.io? You can do this.
Step 1: Configure DNS
Go to your domain registrar (where you bought your domain) and add these DNS records:
- A record: Point to 185.199.108.153, 185.199.109.153, 185.199.110.153, or 185.199.111.153
- CNAME record: Point www to yourusername.github.io
Step 2: Configure GitHub
- In your repository Settings → Pages
- Under "Custom domain", type your domain (e.g., yourdomain.com)
- Check Enforce HTTPS
- Save and wait for the SSL certificate to provision (usually 5-30 minutes)
Your site now loads at your custom domain. DNS propagation can take up to 48 hours, but usually happens within a few hours.
GitHub Pages vs. Alternatives
Here's how GitHub Pages stacks up against other free hosting options:
| Feature | GitHub Pages | Netlify | Vercel |
|---|---|---|---|
| Cost | Free | Free tier | Free tier |
| Custom domain | ✅ Yes | ✅ Yes | ✅ Yes |
| Free SSL | ✅ Yes | ✅ Yes | ✅ Yes |
| Server-side code | ❌ No | ❌ No | ⚠️ Limited |
| Build tools | ⚠️ Jekyll only | ✅ All | ✅ All |
| E-commerce | ❌ No | ⚠️ With plugins | ⚠️ With plugins |
GitHub Pages works fine for static sites. If you need server-side logic or build tools beyond Jekyll, look at Netlify or Vercel instead.
Common Problems and Fixes
404 Error After Deployment
Your default branch might not be "main". In Settings → Pages, verify the branch matches your actual branch name. Some repos use "master" instead.
Changes Not Showing Up
Clear your browser cache. GitHub Pages deployment takes 1-10 minutes. If it's been over 15 minutes, check your commit history to confirm your changes actually saved.
Repository Name Typo
If you named your repo incorrectly, rename it under Settings → Repository name. The URL must match your username exactly.
Images Not Loading
Check your file paths. If your image is at images/photo.jpg, reference it as <img src="images/photo.jpg">. Case sensitivity matters on GitHub.
Quick Reference
- Repository name must be: username.github.io
- Default file: index.html
- Enable Pages in: Settings → Pages → Source → main
- Your URL: https://username.github.io
Is This Worth It?
For simple static sites, yes. The setup takes 15 minutes, costs nothing, and performs well enough for most use cases. The version control integration alone makes it worth it over traditional file-based hosting.
Don't expect to run a web app on this. GitHub Pages serves static files only. No PHP, no databases, no server-side processing. Know what you're getting into before you start.