Please enable JavaScript to use CodeHS

Web Hosting

Deploying a static site

A static site is made of HTML, CSS, and JavaScript files. It does not need a database or a backend program. That makes it one of the easiest kinds of websites to build and deploy.

Deployment ~10 min Middle / High School
The Big Idea

What is a static site?

A static site is a website made of files that do not change for each visitor. The server sends the same HTML, CSS, and JavaScript to everyone. A blog built from files is static. A search engine that builds a different page for every query is dynamic.

Static sites are fast and secure because there is no database to hack and no program generating pages on every request. They are also cheaper to host. For many student projects, portfolios, and small sites, static is the right choice.


Project Files

Your project files

At minimum, a static site needs an index.html file. That is the default page browsers load when they visit a folder. You usually also have a style.css file and maybe a script.js file. Images, fonts, and other assets go in folders like images/ or assets/.

Before uploading, check that your file paths are correct. If your HTML references style.css, the browser will look for it relative to the HTML file. A broken path means a missing stylesheet and an unstyled page.


CS Minute

Git and version control

Git is a tool that tracks changes to your files. It lets you save versions, experiment safely, and collaborate with others. When your files are ready, you can push them to a remote repository on a platform like GitHub, GitLab, or Bitbucket.

Many static hosts connect directly to a Git repository. When you push a new commit, the host automatically builds and deploys your site. This is called continuous deployment. It is one of the reasons static hosting is so convenient for coders.


How It Works

Static hosts

Popular static hosts include GitHub Pages, Netlify, Vercel, Cloudflare Pages, and Surge. They usually give you a free subdomain, like yourname.netlify.app, and let you connect a custom domain later.

The basic flow is: sign up, create a new site, connect your Git repository or drag-and-drop your files, and wait a few seconds for the site to build. You get a live URL you can share.


Security

HTTPS and custom domains

HTTPS encrypts the data between a browser and a server. It protects passwords, personal information, and the content of the page. Modern browsers warn users if a site is not using HTTPS, so it is basically required today.

Most static hosts automatically provide HTTPS, often through a free service called Let's Encrypt. They also let you add a custom domain by pointing your DNS records at their servers. Once the DNS propagates, your domain loads your site with HTTPS.

Tip: always test your site after deploying. Check links, images, and the mobile view. Ask a friend to visit the URL on a different device.


Interactive

Deployment checklist

Check off each step to simulate deploying a static site. The progress bar shows how close you are to going live.

0% complete — start by creating your files.

Code

A GitHub Actions deploy

Deploying a static site can be automatic. This YAML workflow publishes to GitHub Pages every time the main branch is updated.


Your Turn

Check yourself

Why is Git helpful when deploying a website, even if you are working alone?

Your answer:

Sample answer: Git tracks changes, so you can revert mistakes, see what you changed, and push your files to a host. Even alone, it acts as a backup and a history of your project.


Check Yourself

Quick quiz

1. What does a static site need at minimum?

2. What does HTTPS do?

3. Which of these is a popular static host?

Keep learning

You know how to deploy a static site. Next, learn how to keep it running, updated, and secure.

Part of the Web Hosting series.