completefrontend

How to deploy a website for free

Deploying puts your site's files on a server so anyone can open them. Here's how to do it for free with GitHub Pages, what changes when your project has a build step, and what Netlify, Vercel, and Cloudflare Pages add.

Title card for how to deploy a website for free, with a browser address bar showing https://your-name.github.io/my-site/ marked live

You've built your first web page, and it looks great on your laptop. You send it to a friend, and they ask for a link instead. But the page lives only on your computer. Nobody else can open it until you put it online.

To deploy a website for free, upload its files to a free host such as GitHub Pages, Netlify, Vercel, or Cloudflare Pages, and the host gives your site a public address anyone can open. For a site made of HTML, CSS, and JavaScript files, GitHub Pages needs nothing but a GitHub account. Here's what deploying means, a step-by-step walkthrough with GitHub Pages, and what the other hosts add.

What does it mean to deploy a website?

Deploying a website means copying its files to a server. A server is a computer that's always on, always online, and ready to send your pages to anyone who asks. The company that runs it is your host.

It's like moving a painting from your bedroom to a gallery. The painting doesn't change, but now anyone can walk in and see it.

Once your site is deployed, it has a URL: a web address like https://your-name.github.io/my-site/. When someone opens it, their browser asks the host's server for your files, and the server sends them back.

What is the difference between a static site and an app with a server?

A static site is a folder of finished files: HTML, CSS, JavaScript, and images. The host sends the same files to every visitor. The page can still be interactive, because its JavaScript runs in each visitor's browser.

An app with a server also runs code on the host for every request. That code can check a password, build a page for one user, or save a comment to a database, a program that stores data in an organized way.

A static site is like a printed brochure: everyone gets the same copy. An app with a server is like a shop assistant who answers each customer's own question.

Static site App with a server
What you upload Finished HTML, CSS, JavaScript, images Code that runs on the host
What the host does Sends the same files to everyone Runs your code for each request
Good for Portfolios, landing pages, docs, many React apps Logins, saved data, pages built per user
Works on GitHub Pages Yes No

Every host in this guide serves static sites. Netlify, Vercel, and Cloudflare Pages can also run small pieces of server code, called functions. Is Next.js frontend or backend? explains where each kind of code runs.

How do you deploy a website for free with GitHub Pages?

GitHub Pages publishes a site straight from a GitHub repository, a project folder stored on GitHub. With a free account, the repository must be public.

Start with a folder that has an index.html at the top. That file is your home page.

<!doctype html>
<html lang="en">
  <head>
    <title>My site</title>
    <link rel="stylesheet" href="style.css">
  </head>
  <body>
    <h1>Hello, world</h1>
    <script src="script.js"></script>
  </body>
</html>

This page loads style.css and script.js from the same folder. The paths have no slash at the start, which matters once the site is online.

Then follow these steps:

  1. Sign in to GitHub and create a new public repository named my-site.
  2. On the repository page, click Add file, then Upload files, and drag in everything from your folder. If you use Git, push the files instead.
  3. Open the repository's Settings, then click Pages in the sidebar.
  4. Under Build and deployment, set Source to Deploy from a branch.
  5. Pick the main branch and the / (root) folder, then click Save.
  6. Wait a few minutes, then click Visit site on the same screen.
Your folder goes into a GitHub repository, GitHub Pages copies it to its servers, and the site gets a public address. With a build step, you deploy the dist or out folder that npm run build makes
Your files travel from your folder to a public address. With a build step, deploy the folder the build makes.

Your site is now live at https://YOUR-NAME.github.io/my-site/. From now on, every change you push to main goes live by itself. New to pushing? Git and GitHub for beginners walks through it.

Want the shorter address https://YOUR-NAME.github.io? Name the repository YOUR-NAME.github.io instead. Each account gets one site like that.

GitHub Pages is meant for personal, project, and documentation sites. Its rules don't allow running an online store on it.

What if your site has a build step?

Some projects don't ship the code you write. A React or TypeScript project uses a build tool to turn your source files into the finished files browsers get. Bundlers and build tools explains what that step does.

npm run build

This runs the build script listed in the project's package.json, a file that npm and package.json covers. In a Vite project, the finished site lands in a folder named dist. A Next.js static export writes it to out.

Deploy that folder, not your source files. Netlify, Vercel, and Cloudflare Pages run the build for you on every push. On GitHub Pages, set Source to GitHub Actions, a service that runs scripts for your repository. Then add a workflow that builds and publishes the site, like the one in Vite's deploy guide.

What do Netlify, Vercel, and Cloudflare Pages add?

All three connect to your GitHub repository. After that, each push starts a new build and deploy. Each pull request, a proposed change on GitHub, gets its own preview link. You can check the change there before it goes live.

GitHub Pages Netlify Vercel Cloudflare Pages
Free plan Yes, for public repos Yes Yes, the Hobby plan Yes
Runs your build With GitHub Actions Yes Yes Yes
Server code No Functions Functions Pages Functions
Drag-and-drop upload Upload files Netlify Drop Vercel Drop Direct Upload

Netlify lets you drag a folder onto Netlify Drop and get a live site, no Git needed. Its free plan includes custom domains with HTTPS. A custom domain is your own address, like yourname.com, which you buy separately. HTTPS is the secure connection that shows a padlock in the browser.

Vercel maintains Next.js, and deploying a Next.js app there needs no setup. Its free Hobby plan is for personal, non-commercial use. For other ways to run Next.js, see Deploying Next.js.

Cloudflare Pages serves sites from Cloudflare's global network, and it's available on Cloudflare's free plan. For new projects, Cloudflare recommends Cloudflare Workers, which can serve static sites too. A network of servers spread around the world is called a CDN, and CDNs and the edge explains why it makes sites faster.

Why does a site break after you deploy it?

  • Paths that start with a slash. On GitHub Pages, /style.css points to YOUR-NAME.github.io/style.css, outside your my-site folder. Write style.css instead. For Vite, set its base option to '/my-site/'.
  • No index.html at the top. The home page must be named index.html and sit at the top of the folder you publish.
  • Publishing the wrong folder. For a project with a build step, publish dist or out, not the source files.
  • Secrets in the code. Every file of a static site is downloaded by visitors' browsers, so anyone can read it. Never put passwords or private keys in it.
  • Changes that don't show up. Publishing can take a few minutes. Your browser may also show a saved copy, so reload the page. HTTP caching explains why.

Where to go next

Your site is live, so make it worth visiting. Build pages and try ideas in the code editor, with nothing to install. Keep every version of your work safe with Git and GitHub for beginners. Set up your editor with VS Code extensions for frontend developers. When your site grows, why is my website slow shows how to keep it fast.

Written by Shrikanth PS

Senior Software Engineer at Microsoft, working on Copilot Enterprise, with more than nine years in frontend engineering.