Trending
| 8:18 AM IST
Host Your Website Free with GitHub Pages: Step-by-Step Guide (Part 18)
Tech

Host Your Website Free with GitHub Pages: Step-by-Step Guide (Part 18)

GitHub Pages turns a repository into a live website for free. Publish your portfolio, add a custom domain and understand the limits, step by step. Part 18 of our visual Git and GitHub series.

By · Updated · 8 min read 1 view Rate it 0 comments

GitHub Pages is a free service that publishes the HTML, CSS and JavaScript files in a GitHub repository as a live website. Open your repository's Settings, choose Pages, select the main branch as the source and click Save. Within a few minutes your site is online at an address like username.github.io/project, with HTTPS included.

A small hospital in Vijayawada asked Sneha's studio for a quote, then asked a question that stopped her: "Can we see some of your earlier work?" Her best projects were private client sites, and her own portfolio existed only on GitHub as code. A recruiter or client cannot "see" code. That weekend she published her portfolio with GitHub Pages, and her next proposal included a live link. Your portfolio from Part 7 has been on GitHub since Part 9. In this Part 18 we turn it into a real website anyone can open on their phone, for free.

Your one-minute summary

  • GitHub Pages hosts static websites (HTML, CSS, JavaScript) for free
  • Turn it on in Settings → Pages; choose main and / (root)
  • Your address: username.github.io/repository-name
  • A repo named username.github.io becomes your main personal site
  • You can connect a custom domain, with free HTTPS
  • It does not run PHP or databases, and is not for online shops

What can GitHub Pages host?

GitHub Pages serves static files: what is in your repository is exactly what visitors receive. GitHub's documentation, About GitHub Pages, notes that it does not support server-side languages such as PHP, Ruby or Python.

Is GitHub Pages right for my site?

Great fit

  • Personal portfolios and resumes
  • Project and documentation sites
  • Event, wedding or college club pages
  • Landing pages and simple information sites
  • Sites built with static generators

Not a fit

  • PHP or WordPress sites
  • Sites needing a database or user logins
  • Online shops and payment flows
  • Anything handling passwords or card numbers
  • Commercial SaaS products

The bakery's booking system stays on regular hosting; Sneha's portfolio is perfect for Pages.

How do I publish my site with GitHub Pages?

Your repository needs an index.html in its main folder; that becomes the home page. Then:

Publishing in five clicks

1. Open the repository on GitHubFor example github.com/snehareddy/my-portfolio
2. Go to Settings, then PagesIn the left sidebar under "Code and automation"
3. Source: Deploy from a branchChoose branch main and folder / (root), then Save
4. Wait a minute or twoThe Actions tab shows the deployment running
5. Visit your siteThe Pages settings show the live address and a "Visit site" button

From now on, every push to main updates the live site automatically.

Public repositories on the Free planAccording to GitHub's Pages limits page, GitHub Pages is available in public repositories with GitHub Free, and in private repositories on paid plans such as GitHub Pro. If your repository is private on the Free plan, make it public before enabling Pages, after checking it contains no secrets (Part 10).
Also readGitHub Actions for Beginners: Let GitHub Test and Deploy Your Website Automatically (Part 19)

What is the difference between a user site and a project site?

User siteProject site
Repository nameExactly username.github.ioAny name, such as my-portfolio
Web addresshttps://username.github.iohttps://username.github.io/my-portfolio
How many?One per accountOne per repository
Best forYour main personal or portfolio siteIndividual projects and demos

What are the limits of GitHub Pages?

The limits are generous for personal sites. GitHub's documentation lists these usage limits:

GitHub Pages limits at a glance

1 GBmaximum size of a published site
100 GBsoft bandwidth limit per month
10builds per hour (soft limit, when publishing from a branch)
10 mindeployment timeout

Source: GitHub Pages limits. Pages is not intended as free hosting for online businesses or e-commerce.

Keep image sizes small (compress photos before committing) and you will rarely come close to these limits with a portfolio or small information site.

How do I use my own domain name?

You can point a domain you have bought, such as snehareddy.in, to your GitHub Pages site. HTTPS remains free.

Connecting a custom domain

Buy a domainFrom any domain registrar
Add DNS recordsAt your registrar, add the records listed in GitHub's custom domain guide
Enter it in GitHubSettings, Pages, Custom domain, Save
Wait for DNSUsually minutes, sometimes up to a day
Tick Enforce HTTPSFree certificate, padlock in the browser

GitHub also recommends verifying your domain in your account settings to prevent takeovers.

What are common GitHub Pages problems?

Problem and fix

404 page

  • No index.html in the chosen folder
  • Or it is called Index.html; names are case-sensitive

CSS or images missing

  • Links like /style.css break on project sites
  • Use relative paths: style.css, images/photo.jpg

Changes not showing

  • Wait a minute and check the Actions tab
  • Hard-refresh the browser

PHP shows as text

  • Pages cannot run PHP
  • Use regular hosting for PHP sites

From code to client proposal

Code on your laptopOnly you can see it
Pushed to GitHubDevelopers can read it
Live on GitHub PagesAnyone can open it on a phone
Link in your CV and proposalsClients and recruiters see real work

Launch checklist

  • index.html is in the repository's main folder
  • All links and images use relative paths
  • Images are compressed
  • No API keys or private data in the repository
  • Site tested on a phone and a laptop
  • Live link added to your README and GitHub profile

Her View

For many students and first-time freelancers, paying for hosting feels like a hurdle before they have earned anything. GitHub Pages removes that hurdle. A live portfolio link on your CV or LinkedIn says "I build real things" more clearly than any certificate. Publish early, even if it is simple; you can improve it with every push.

Also readPull Requests on GitHub Explained: Propose, Review and Merge Changes (Part 14)

His Insight

Use GitHub Pages for what it does best: fast, free, static sites. Keep secrets out of public repositories, and use a proper host for anything with PHP, databases or payments. Because every push to main redeploys the site, the GitHub flow from Part 16 becomes your release process: branch, review, merge, and it is live.

H View Verdict

GitHub Pages is the easiest way to put a static website online for free, with HTTPS and optional custom domains. Your portfolio is now live. In Part 19, we let GitHub do routine jobs for you with GitHub Actions, including checks that run on every pull request.

Self-assessment: test yourself

Ready? Tap an option for each question. You will see right away whether you got it, with a short explanation, and your score at the end. Take your time, and try again as often as you like.

GitHub Pages quiz: 10 questions

1. Where do you turn on GitHub Pages?

  1. In VS Code
  2. Repository Settings, then Pages
  3. Your profile README
  4. The Issues tab

Pages is configured in the repository's settings.

2. Which file becomes your home page?

  1. README.md
  2. index.html
  3. .gitignore
  4. style.css

index.html in the chosen folder is served as the home page.

3. Can GitHub Pages run a PHP website?

  1. Yes, always
  2. Only with a paid plan
  3. No, it only serves static files
  4. Only on custom domains

GitHub Pages does not support server-side languages like PHP.

4. What repository name creates your main user site?

  1. website
  2. main
  3. username.github.io
  4. pages

A repository named username.github.io publishes to https://username.github.io.

5. What is the maximum size of a published GitHub Pages site?

  1. 100 MB
  2. 1 GB
  3. 10 GB
  4. Unlimited

GitHub's documentation says published sites may be no larger than 1 GB.

6. Your CSS loads locally but not on GitHub Pages. A likely cause is

  1. CSS is not allowed
  2. Absolute paths like /style.css on a project site
  3. Your internet is slow
  4. You need a paid plan

Use relative paths so files load from the project folder.

7. Is GitHub Pages suitable for an online shop taking payments?

  1. Yes
  2. No; GitHub says it is not for e-commerce
  3. Only during sales
  4. Only with HTTPS

Use proper hosting for commercial transactions.

8. After enabling Pages, how do you update the live site?

  1. Email GitHub
  2. Push new commits to the published branch
  3. Re-create the repository
  4. Upload a ZIP

Each push to main redeploys the site automatically.

9. What is the soft bandwidth limit per month?

  1. 1 GB
  2. 10 GB
  3. 100 GB
  4. 1 TB

GitHub lists a soft limit of 100 GB per month.

10. Can you use your own domain with GitHub Pages?

  1. No
  2. Yes, with DNS records and free HTTPS
  3. Only .com domains
  4. Only for organisations

Custom domains are supported, with HTTPS available for free.

Frequently asked questions

Is GitHub Pages really free?

Yes, for public repositories on the Free plan, including HTTPS. You only pay if you buy a custom domain or need Pages for private repositories on a paid plan.

Can I use GitHub Pages for a client's business website?

A simple information site is generally fine, but GitHub says Pages is not intended for online businesses, e-commerce or commercial transactions. Use regular hosting for shops and payment flows.

How long does an update take to go live?

Usually under a couple of minutes after you push. Check the Actions tab if it takes longer.

Can I host a React or Vue site?

Yes, after building it into static files. A GitHub Actions workflow can build and deploy it automatically on each push, which leads nicely into Part 19.

Part 18 of 20 in our Git and GitHub for Beginners series. A small tip from us: once your site is live, open it on your phone and share the link with one person you trust for honest feedback. Next up, Part 19: GitHub Actions basics.
Topics: Tech
Harika Behara

Writes for H View, where every story follows our editorial policy and is reviewed before it is published.

All stories by Harika →

H View stories follow our editorial policy. Spotted an error? Tell us and we will correct it.

Rate this article

One tap is enough. No comment needed.

Your rating
Be the first to rate it.

Was this article helpful?

Your answer goes straight to our editors.

Comments0

Be kind and stay on topic. Comments with links are checked before they appear.

No comments yet. Start the conversation.

The H View Brief

Our best stories, in your inbox.

The week’s best Her View, His Insight reading in one short, useful note.

Free. We only use your email to send The H View Brief. Unsubscribe any time.