Stop 09 · Git & GitHubProjects · 1/1

Publish a Site on GitHub Pages

Part of the Web Development Roadmap

In short

A recruiter won't download your zip file, but they will click a link. GitHub Pages turns any HTML, CSS and JavaScript repo into a free live website in a couple of minutes.

GitHub Pages hosts a static site for free straight from a repository, giving your HTML, CSS and JavaScript projects a live URL to share.

The jaadu hangs a bright framed painting in a shop's front display window while passers-by stop on the pavement to look.

Think of it like this

Putting your painting in the gallery window

Your painting is finished and stored safely in the gallery's back room. Anyone can ask to see it, but almost nobody will. Move it into the front window, and everyone walking past sees it. Your repo is the back room. GitHub Pages moves it to the window with its own address.

The big ideas

What you need to know

Static sites only

Pages serves HTML, CSS, JS and images. It can't run a Node.js backend or a database.

index.html is the front door

The file must be called index.html, in lowercase, at the root (or in /docs if you pick that folder).

Paths need care

Your site lives at /repo-name/. A link like /style.css looks at the domain root and breaks. Use relative paths like style.css.

Updates are automatic

Every new push to main redeploys the site within a minute or two.

How it works

From repo to live link

  1. 1

    Push your site

    Make sure index.html is in the root of the repo and pushed to main.

  2. 2

    Open Settings

    In your repo, go to Settings, then Pages.

  3. 3

    Pick the source

    Choose Deploy from a branch, then branch main and folder / (root). Save.

  4. 4

    Wait a minute

    GitHub builds the site and shows the URL at the top of the Pages screen.

  5. 5

    Test on your phone

    Open https://your-name.github.io/repo-name/ and check every link and image.

See it in code

Walk through the code

bash
1# check the structure: index.html must be at the root2ls3# index.html  style.css  app.js  images/4 5git add .6git commit -m "Ready to publish"7git push8 9# then on GitHub: Settings > Pages > Deploy from a branch > main / (root)10# your site: https://your-name.github.io/portfolio/

1/3index.html at the top level, not hidden inside a src or project folder.

Deployment itself is a few clicks. Most problems come from file names and paths, so check those first.

Save yourself the pain

Common mistakes

Oops

Naming the file Index.html or home.html.

Do this instead

It must be index.html, all lowercase. GitHub's servers treat file names as case-sensitive.

Oops

Using paths like /images/logo.png that work locally but break online.

Do this instead

Use images/logo.png (no leading slash) so the path stays inside /repo-name/.

Your mission

Go live

~20 min

Quick check

Your site works locally but on GitHub Pages the CSS doesn't load. The link is href="/style.css". Why?

Go deeper

  1. 1Publish your landing page on GitHub Pages and check it on your phone.
  2. 2Fix any broken links caused by wrong relative paths.
  3. 3Add the live link to the repository's About section and README.

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge