GitHub Pages- How to Create Your Own Website for Free

What GitHub Pages Actually Is

GitHub Pages is free static website hosting built into GitHub. You push code to a repository, and GitHub serves it as a website. No servers to maintain, no hosting bills, no configuration headaches.

It works for personal blogs, project documentation, portfolios, and landing pages. If you need dynamic features like a database or server-side processing, this isn't your solution.

What You Get for Free

The only real cost is your time to set it up.

What You Don't Get

GitHub Pages is static only. No PHP, no databases, no server-side code. Your site must be pure HTML, CSS, and JavaScript. If that sounds limiting, you probably don't need GitHub Pages.

Prerequisites

That's it. No credit card, no paid tools needed.

How to Set Up Your First GitHub Pages Site

Step 1: Create a Repository

Go to GitHub and click New Repository. Name it exactly like this:

username.github.io

Replace "username" with your actual GitHub username. This naming convention tells GitHub to automatically serve the repo as a website.

Step 2: Upload Your Files

You need an index.html file at minimum. You can:

Here's the bare minimum to get started:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>My Site</title>
</head>
<body>
    <h1>Hello, world</h1>
    <p>This is my free website.</p>
</body>
</html>

Step 3: Enable GitHub Pages

Go to your repository Settings β†’ scroll to Pages.

Under "Source," select:

Click Save. Wait 1-2 minutes. Your site goes live at:

https://username.github.io

Adding a Custom Domain

Skip this if you're fine with the default .github.io URL.

Buying a Domain

Buy a domain from anywhereβ€”Namecheap, Google Domains, Cloudflare. Doesn't matter. You'll spend around $10-15 per year.

Configuring DNS

Add these records at your domain registrar:

Connecting to GitHub Pages

In your repo Settings β†’ Pages β†’ Custom domain, enter your domain name. Check Enforce HTTPS. GitHub handles the SSL certificate automatically through Let's Encrypt.

DNS changes take up to 48 hours to propagate, though it's usually faster.

Using Jekyll for Static Sites

Jekyll is a static site generator built into GitHub Pages. Instead of writing raw HTML for every page, you write content in Markdown and Jekyll converts it to HTML.

Jekyll is useful for blogs and documentation. If you're building a simple landing page, you don't need it.

Jekyll Quick Start

Create a file named _config.yml in your repo root:

title: My Site
description: What the site is about
theme: minima

Create a folder named _posts and add a file like 2024-01-15-welcome.md:

---
layout: post
title: "Welcome"
---
This is my first post. Jekyll converts this Markdown to HTML.

GitHub automatically builds your Jekyll site when you push. No local build process needed.

GitHub Pages vs Alternatives

Feature GitHub Pages Netlify Vercel
Cost Free Free tier available Free tier available
Custom domain βœ“ βœ“ βœ“
Auto HTTPS βœ“ βœ“ βœ“
Built-in CI/CD βœ“ βœ“ βœ“
Server-side rendering βœ— βœ— βœ“ (with extra config)
Form handling βœ— βœ“ βœ—
Ease of setup Moderate Easy Easy

GitHub Pages wins for pure simplicity and cost. If you need forms or server-side features, look at Netlify.

Common Problems and Fixes

Site Not Updating

GitHub Pages builds can take 2-3 minutes. If you pushed and nothing changed, wait before panicking. Also check that your source branch and folder are correct in Settings.

404 Errors on Internal Pages

GitHub Pages doesn't support clean URLs by default. Use index.html extensions or enable Jekyll's permalink settings.

Theme Not Loading

If you're using a Jekyll theme and it looks broken, check your _config.yml for syntax errors. GitHub Pages shows build errors in the Actions tab.

Who Should Use This

Use GitHub Pages if:

Don't bother if:

The Bottom Line

GitHub Pages is free, fast, and reliable. It works exactly as advertised. The setup takes 15-30 minutes if you're starting from scratch. Your site will load fast, stay online, and cost you nothing.

The main limitation is that you're building a static site. If that's what you need, there's no reason to pay for hosting.