How to Start a Free Static Website with GitHub Pages
Step-by-step instructions for deploying a free static site using GitHub Pages, HTML, and CSS. Includes decision criteria for Netlify and Vercel.
Recommended
Recommended Web Hosting
The Best Web Hosting - Free Domain for 1st Year, Free SSL Certificate, 1-Click WordPress Install, Expert 24/7 Support. Starting at CA$2.99/mo* (Regularly CA$8.49/mo). Recommended by WordPress.org, Trusted by over 5 Million WordPress Users.
Choose GitHub Pages if you need a simple, version-controlled static site. Choose Netlify if you require built-in form handling or drag-and-drop workflows. Choose Vercel if you plan to scale to Next.js later.
Overview
This guide explains how to start a website from scratch for free using GitHub Pages, HTML, CSS, and basic JavaScript. You will learn to pick a free host, create a Git repository, write the initial code, deploy via GitHub Pages, and validate the site.
Why this matters: entrepreneurs, freelancers, and developers can validate ideas fast, showcase portfolios, or launch landing pages without hosting overhead. The skills taught are portable to paid hosting and more advanced workflows.
Prerequisites: a computer, internet access, a free GitHub account, and a basic text editor (VS Code recommended). No prior web hosting purchase required.
Time estimate: 2 to 4 hours total if you follow every step, less if you reuse templates.
Step 1: Plan Your Site
Action to take: decide the purpose, content, pages, and basic structure. Sketch a sitemap with 3 to 5 pages: Home, About, Services/Products, Contact, and a blog or portfolio if needed.
Why you are doing it: planning prevents rework and scope creep. A small clear plan helps you choose templates, file names, and routes. It also defines the content you will write and images you need.
Example checklist:
- Define the goal (collect leads, show portfolio, inform users).
- Choose 3-5 pages and their content.
- Select a color and font pair (Google Fonts).
- Write 150-300 words for the Home page headline and summary.
Expected outcome: a one-page sketch and content list ready to convert to HTML. This reduces the time spent editing layout later.
Common issues and fixes:
- Problem: Unclear goal leads to endless edits. Fix: pick the single most important action for visitors and optimize for that.
- Problem: Too many pages. Fix: merge similar pages and start with a single-page layout if unsure.
Time estimate: ~10 minutes
Step 2: Choose Free Hosting and a Domain
Action to take: pick a free static hosting provider and decide whether to use a free subdomain or configure a custom domain later. Recommended providers: GitHub Pages, Netlify, Vercel, Cloudflare Pages.
Why you are doing it: free static hosts provide SSL, fast CDN, and simple deploys for HTML/CSS/JS sites. They eliminate server management for typical landing pages and portfolios.
Concrete choices:
- GitHub Pages: free for public repos, straightforward for static sites and Jekyll.
- Netlify: drag-and-drop deploys, CI, redirects, and forms.
- Vercel: optimized for Next.js and static front ends.
- Cloudflare Pages: fast global build and deploy.
Steps to take:
- Create a free GitHub account at https://github.com.
- Choose GitHub Pages for simplicity or Netlify for form handling.
- If you want a custom domain now, buy one from Namecheap or use a free domain service; optional.
Expected outcome: you have identified the host and account created, ready for deployment.
Common issues and fixes:
- Problem: Private repo prevents Pages deployment. Fix: set repo to public or use Netlify which supports private repos via OAuth.
- Problem: DNS confusion with custom domains. Fix: follow host docs and use Cloudflare DNS for easy management.
Time estimate: ~10 minutes
For more detail, see How Start a Website for Free Step by Step.
Step 3: Create a Git Repository and Initial Site Files
Initialize your project directory, create your HTML/CSS files, and push to a new GitHub repository.
Why you are doing it: version control tracks changes, makes deployment to GitHub Pages straightforward, and enables collaboration.
Commands and example:
- Open a terminal in your project folder.
- Run these commands to initialize and push:
git init
git add index.html styles.css README.md
git commit -m "Initial site files"
git branch -M main
git remote add origin https://github.com/YOUR-USERNAME/YOUR-REPO.git
git push -u origin main
Replace YOUR-USERNAME and YOUR-REPO with real values.
Expected outcome: a public repo on GitHub containing your initial files. GitHub will serve the repo for Pages deploy if configured.
Common issues and fixes:
- Problem: push rejected due to missing main branch. Fix: use
git branch -M mainbefore push. - Problem: credential errors. Fix: set up SSH keys or use a personal access token for HTTPS pushes.
Time estimate: ~10 minutes
Step 4: Build a Simple HTML/CSS/JS Page Locally
Action to take: create a minimal responsive homepage using HTML, a CSS file, and a small JavaScript snippet.
Why you are doing it: building a basic site from scratch teaches structure and behavior and produces a portable template you can reuse.
Example index.html (minimal):
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>My Free Site</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header><h1>My Project</h1></header>
<main>
<p>Launch your idea with this simple page.</p>
<a href="mailto:you@example.com">Contact</a>
</main>
<script src="main.js"></script>
</body>
</html>
Add CSS for styling and JS for interactivity.
Expected outcome: a working local site you can open in a browser using file:// or with a local server like Live Server in VS Code.
Common issues and fixes:
- Problem: layout breaks on mobile. Fix: ensure viewport meta tag and use responsive CSS (flexbox).
- Problem: local files blocked by CORS for AJAX. Fix: use a local static server (
python -m http.serveror VS Code Live Server).
Time estimate: ~10 minutes
Step 5: Deploy to GitHub Pages and Verify
Action to take: publish the repository to GitHub Pages and confirm the live URL.
Why you are doing it: deploying makes your site accessible to the public and proves the workflow from local files to live site.
Steps:
- On GitHub, go to Settings > Pages for your repo.
- Under Source, choose branch: main and folder: / (root) or /docs.
- Save and wait a minute. GitHub will provide a URL like https://your-username.github.io/your-repo.
Expected outcome: your site is served at the GitHub Pages URL over HTTPS.
Common issues and fixes:
- Problem: blank page after deploy. Fix: confirm index.html is at repo root and paths to CSS/JS are correct.
- Problem: 404 on root URL. Fix: ensure branch selected and commit pushed; check Pages settings for build errors in the repo Actions tab.
Time estimate: ~10 minutes
Related: How to Build a Website for Free: Which Method is Best?.
Step 6: Improve, Add Analytics, and Optionally Set a Custom Domain
Action to take: add SEO meta tags, link Google Fonts, install basic analytics, and configure a custom domain with DNS.
Why you are doing it: SEO/meta tags help search engines; analytics helps measure traffic; a custom domain improves branding.
Conservative steps:
- Add meta description and Open Graph tags to head.
- Add analytics like Plausible (privacy-friendly) or Google Analytics via a small script.
- For a custom domain: in your repo add a CNAME file containing example.com, then set DNS A records to the host’s IPs or add CNAME to your host per provider instructions.
Example CNAME file content:
example.com
Expected outcome: better discoverability, traffic metrics, and optional branded domain pointing to your site.
Common issues and fixes:
- Problem: mixed content errors when domain not set to HTTPS. Fix: enable HTTPS via your host (GitHub Pages supports HTTPS for custom domains once DNS is correct).
- Problem: analytics blocked by ad blockers. Fix: use server-side analytics or privacy-first providers.
Time estimate: ~10 minutes
Testing and Validation
How to verify it works with checklist:
- Open the live URL in a browser and verify the Home page content loads.
- Test on mobile and desktop (resize browser or use device emulation).
- Check that links and contact form/mailto work.
- Confirm HTTPS is active and no mixed content warnings exist.
- Use Lighthouse in Chrome DevTools for a quick performance, accessibility, and SEO report.
Run simple tests: curl -I to confirm 200 response. Use w3.org/css-validator for CSS.
Common Mistakes
- Missing index.html at repo root - Fix by ensuring index.html is committed to the folder you served.
- Wrong resource paths - Fix by using relative paths and testing locally with a static server.
- Forgetting to set repository settings for Pages - Fix by selecting the correct branch and folder in GitHub Pages settings.
- Skipping meta tags and accessibility - Fix by adding descriptive title, meta description, and alt attributes for images.
Avoid these by testing frequently, using version control, and validating with automated tools.
See also: How to Build a Website for a Business Free Guide.
Next Steps
After you have a live free site, iterate on content and design. Add more pages, implement an accessible navigation, and improve performance using image optimization and caching. Consider frameworks like Astro or Next.js to manage larger sites and dynamic content.
Set measurable goals like conversion or visitor targets and monitor analytics to guide improvements.
Further Reading
How to Start a Website From Scratch: Compare Static vs. Dynamic Hosting Costs.
How to Start a Website on Macbook: GitHub Pages vs Netlify Comparison
Sources & Citations
- https://github.com.
- https://github.com/YOUR-USERNAME/YOUR-REPO.git
- https://your-username.github.io/your-repo.
Learn more in our guide to How to Start a Blog Website Free.
Decision Matrix
| Scenario | Recommendation | Why |
|---|---|---|
| Deploying a simple HTML/CSS portfolio | GitHub Pages | It requires zero configuration for public repos and integrates directly with your existing version control workflow. |
| Need contact forms without backend code | Netlify | It provides built-in form handling and submission storage, eliminating the need for third-party services like Formspree. |
| Planning to use Next.js or React later | Vercel | It offers optimized builds and preview deployments specifically designed for React-based frameworks out of the box. |
| Hosting a private repository | Netlify or Vercel | GitHub Pages requires public repositories for free static hosting, whereas Netlify and Vercel support private repos via OAuth. |
| Managing DNS for a custom domain | Cloudflare Pages or Netlify | They offer robust DNS management tools and fast global edge networks, reducing configuration complexity compared to manual GitHub Pages setup. |
Recommended Next Step
Review the detailed comparison in Create a Website for Business Step by Step to understand how these free tools fit into a broader business strategy. If you are ready to deploy, follow the GitHub Pages setup guide for immediate action.
FAQ
Is GitHub Pages really free for commercial use?
Yes, GitHub Pages is free for public repositories and allows personal and commercial static sites under GitHub’s terms. You must read GitHub’s specific terms of service for detailed compliance requirements.
Can I use a custom domain for free?
You generally need to buy a custom domain as registration is rarely free. However, you can use free subdomains provided by hosts like Netlify or Vercel to start without upfront costs.
How do I add forms on a free static host?
Use third-party services like Formspree, Netlify Forms, or serverless functions from Netlify/Vercel. These handle submissions without requiring you to manage a backend server.
How do I back up my static site?
Keep your site in a git repository and push to GitHub regularly. You can also export content periodically or use another remote mirror to ensure data safety.
Do I need coding knowledge to start?
No, you can use templates or static site generators. However, basic HTML and CSS knowledge helps significantly when customizing layouts and maintaining the site long-term.
Frequently Asked Questions
How do I initialize a Git repository for my website project?
git init to create a new local repository. After adding your initial site files with git add, you commit them and link the local repo to a remote host like GitHub using a personal access token or SSH keys for authentication.What files do I need to create a basic website locally?
index.html file for the core structure and content, alongside a styles.css file for visual styling. Including a viewport meta tag in your HTML ensures the layout remains responsive and adapts properly to mobile devices.How long does it take to build a website from scratch?
Can I use my own domain name with free hosting?
Next step
Recommended Web Hosting
The Best Web Hosting - Free Domain for 1st Year, Free SSL Certificate, 1-Click WordPress Install, Expert 24/7 Support. Starting at CA$2.99/mo* (Regularly CA$8.49/mo). Recommended by WordPress.org, Trusted by over 5 Million WordPress Users.
