Introduction
If you’ve built a simple HTML template and want to put it online without spending a dime, GitHub Pages is one of the easiest hosting platforms to get started with. It’s free, reliable, and great for beginners. In this guide, you’ll learn how to host a static HTML website on GitHub Pages in just a few minutes.
How to Host a Static HTML Template on GitHub Pages (Step-by-Step Guide)
Why Use GitHub Pages?
- 100% free hosting for static sites
- No server setup required
- Built-in HTTPS (SSL certificate)
- Perfect for portfolios, landing pages, and small projects
Prerequisites
Before starting, make sure you have:
- A GitHub account (sign up at github.com).
- Git is installed on your computer (optional if you upload via web).
- A static website (e.g.,
index.html
, CSS, and JS files).
Step 1: Create a GitHub Repository
- Log in to GitHub.
- Click the + New repository button.
- Name your repository (e.g.,
my-website
). - Set it to Public and click Create repository.
See Also: How to Deploy a Next.js Template to Vercel (Complete Tutorial)
Step 2: Upload Your Template
Option A: Upload via GitHub website
- Drag and drop your HTML, CSS, and JS files into the repository.
- Make sure you have an
index.html
file at the root.
Option B: Upload via Git
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/username/my-website.git
git push -u origin main
Step 3: Enable GitHub Pages
- Go to your repository → Settings.
- Scroll to Pages.
- Under “Branch,” select main and /root.
- Click Save.
Within a few minutes, your site will be live at: https://username.github.io/my-website
Step 4: Add a Custom Domain (Optional)
Want your own domain (e.g., mywebsite.com
)?
- Buy a domain from providers like Namecheap, GoDaddy, or Google Domains.
- In Settings > Pages, add your domain.
- Update your domain’s DNS records (CNAME →
username.github.io
).
Troubleshooting Tips
- Page not loading? Double-check you have an
index.html
at the root. - CSS/JS not working? Use relative paths like
./style.css
. - Still broken? Wait a few minutes—DNS & GitHub Pages sometimes take 5–10 minutes.
Conclusion
You’ve successfully hosted your first template on GitHub Pages! This method is perfect for portfolios, resumes, and static projects. Next, we’ll move to Vercel, which is ideal for React and Next.js templates.
Bookmark this guide and check out our full Hosting Academy series.