Home Career and Growth How to Host Websites with GitHub Pages

How to Host Websites with GitHub Pages

282
0

If you want to host a website for free—without servers, domain costs, or complicated setup—GitHub Pages is one of the easiest ways to do it. Whether you’re a student, developer, blogger, or small business owner, you can publish a website in minutes.

In this guide, we’ll learn what GitHub Pages is, why it’s useful, and how to publish your website step-by-step.


🌐 What Is GitHub Pages?

GitHub Pages is a free hosting service from GitHub that lets us publish websites directly from our GitHub repositories.

We can use it to host:

  • Personal portfolios
  • Project websites
  • Documentation sites
  • Blogs
  • Static HTML/CSS/JS websites

No backend or server required.


✨ Why Use GitHub Pages?

Here are the biggest reasons beginners love it:

  • Free hosting forever
  • No coding required beyond simple HTML
  • Easy to update (just push changes to GitHub)
  • Works with custom domains
  • Supports static site generators like Jekyll

🚀 What You Need Before Starting

  • A GitHub account (free)
  • Basic knowledge of uploading files to a repository
  • Your website files (like index.html)

⭐ Different Ways of Creating GitHub Pages Sites

GitHub Pages supports two website types in the same user account:


🔹 Option 1: Personal Website (Main Homepage)

This is your primary GitHub Pages website, available at:

https://your-username.github.io

Repository Naming Rule

The repository name must be exactly:

your-username.github.io

Example (using username heartin):

You can have only ONE personal site.

This is best for:

  • Portfolio
  • Resume
  • Personal homepage

🔹 Option 2: Project Websites (Unlimited Extra Sites)

You can create unlimited project websites, one for each repository.

URL format:

https://your-username.github.io/repository-name

Repository Naming Rule

The repository name can be anything.

Examples (using username heartin):

Repo NameURL
portfoliohttps://heartin.github.io/portfolio
resume-sitehttps://heartin.github.io/resume-site
weather-apphttps://heartin.github.io/weather-app

Best for:

  • Experiments
  • Assignments
  • Demo apps
  • Documentation projects

🧱 Common Steps for Creating GitHub Pages Sites (Option 1 or 2)

Regardless of which option you choose, the setup steps are mostly the same.


Step 1 — Create a Repository

Choose the correct repository name depending on your option:

✔️ For Personal Site (Option 1):

your-username.github.io

Example:
heartin.github.io

✔️ For Project Sites (Option 2):

any-repo-name

Examples:
portfolio, resume-site, weather-app

Then:

  1. Go to GitHub
  2. Click New Repository
  3. Enter the repo name
  4. Click Create Repository

Step 2 — Add Your Website Files

Files to upload:

  • index.html (required)
  • style.css (optional)
  • script.js (optional)
  • images, folders, assets

Example index.html

<!DOCTYPE html>
<html>
<head>
  <title>Welcome to My Website</title>
</head>
<body>
  <h1>Hello from GitHub Pages!</h1>
</body>
</html>

Step 3 — Enable GitHub Pages

  1. Open the repository
  2. Go to Settings
  3. Scroll to Pages
  4. Under Source, select:
    • Branch: main
    • Folder: / (root)
  5. Click Save

GitHub generates your website URL automatically.


Step 4 — Visit Your Live Website

✔️ Personal Site (Option 1)

General:

https://your-username.github.io

Example:

https://heartin.github.io

✔️ Project Site (Option 2)

General:

https://your-username.github.io/repository-name

Examples:

https://heartin.github.io/portfolio
https://heartin.github.io/resume-site
https://heartin.github.io/weather-app

Your website is now live!


🌐 (Optional) Add a Custom Domain

You can connect any custom domain (e.g., www.heartinJK.com) to your GitHub Pages website.


Step 1 — Add Domain in GitHub

  1. Go to Settings → Pages
  2. Enter your custom domain URL
  3. Save
  4. GitHub will create a CNAME file automatically

Step 2 — Add DNS Records

At your domain provider, add:

CNAME Record

TypeHostPoints To
CNAMEwwwyour-username.github.io

Example
For username heartin:

TypeHostPoints To
CNAMEwwwheartin.github.io

Step 3 — (Optional) Root Domain Redirect

To redirect:

heartinjk.com → www.heartinjk.com

Add these A records:

185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153


Step 4 — Enable HTTPS

When DNS completes:

  1. Go to Settings → Pages
  2. Enable Enforce HTTPS

Your custom domain is now working.


🧠 Quick Summary

FeatureOption 1: Personal SiteOption 2: Project Sites
Repo Nameyour-username.github.ioAny name
Example Repoheartin.github.ioportfolio, resume-site
URLusername.github.iousername.github.io/repo-name
Example URLhttps://heartin.github.iohttps://heartin.github.io/portfolio
AllowedOnly 1Unlimited
Best UsePortfolio / ResumeDemos / Projects

🧪 Testing and Updating Your Website

Whenever we want to make changes:

  1. Edit the files
  2. Commit and push to GitHub
  3. Refresh our published website

Changes usually appear within seconds.


💡 Tips for Beginners

  • Your website must have a file named index.html
  • File names are case-sensitive
  • Use the built-in GitHub Pages themes if you don’t want to write HTML
  • Use README.md for simple documentation-style pages

🎁 Final Thoughts

GitHub Pages is one of the easiest and most beginner-friendly ways to publish a website. It’s free, simple, and powerful enough for portfolios, documentation, and even full static sites.

If you follow the steps above, you can publish your website within 5 minutes.

Previous articleHow to Use the Git Panel in Visual Studio Code (VS Code)
Next articleIntroduction to GitHub Actions
Heartin Kanikathottu
As a seasoned Cloud and Security Architect, I’ve led transformative initiatives in key roles, including Vice President at Morgan Stanley, Principal Architect at Societe Generale, and Tech Lead & Cloud Security Architect at VMware, among others. I’m also an internationally published author with multiple books available on platforms like Amazon and O'Reilly. Notably, one of my books was recognized as the 8th best cloud computing book of all time in 2020, reflecting the impact of my contributions to the field. With over 15 professional certifications from providers such as Microsoft (Azure), Amazon (AWS), Oracle (Java), Pivotal (Spring), and IBM, I bring a wealth of expertise to my work. Academically, I hold dual Master’s degrees in Cloud Computing and Data Analytics. I’m passionate about sharing knowledge and mentoring others, which is why I actively speak at global technical forums such as Tech Opportunities Fest at Platform Calgary, Google's Kubernetes Meetup, Java User Group, Elasticsearch Meetup, and the Agile India Conference.

LEAVE A REPLY

Please enter your comment!
Please enter your name here