Free, independent guides since 2010

Hosting & domains

Static site hosting: fast, cheap and secure

How hosting a static website works: static hosts and CDNs, free tiers, deploying from Git, custom domains, HTTPS, redirects, forms and when static hosting is not enough.

<guide section="Hosting & domains" type="article" read="1 min"/>

This very website is a static site: plain HTML, CSS and images, served directly to your browser. Static hosting is one of the biggest improvements in web hosting of the past decade. Read static site or WordPress? for the comparison; this page is about where and how to host one.

How it works

A static host stores your files and delivers them from servers around the world (a CDN). There is no database or PHP to run, so there is little to break, attack or update.

Options

OptionGood for
Static hosting platforms with Git integrationDevelopers, automatic deploys on every change
CDN providers with static asset hostingSpeed worldwide, redirects and headers via simple files
Regular shared hostingStatic files work on any web host too
Code repository pagesDocumentation and personal projects

Deploying

  1. Create a project and connect a Git repository, or upload a folder.
  2. Set the build command if you use a static site generator, or none for plain HTML.
  3. Add your custom domain and update your DNS records.
  4. HTTPS is usually activated automatically (see HTTPS).

Redirects and headers

Most static hosts read a redirects file and a headers file from your project. That is how you keep old URLs working after a migration (see moving without losing rankings) and set security headers such as a Content Security Policy.

Adding dynamic features

  • Forms: form services or serverless functions.
  • Search: a pre-built JavaScript search index, like the search on this site.
  • Comments: external comment systems, or simply email.
  • Shop: embedded buy buttons from a payment provider.

Frequently asked questions

Is static hosting really free?

Many static hosting platforms and CDNs have free tiers with generous limits for small sites. Paid plans add features such as team access, more build minutes or advanced analytics.

Can a static site have a contact form?

Yes, through a form service, a serverless function, or the form feature some static hosts include.