Sites built with static generators or single-page frameworks are just files. Static website hosting on S3 storage serves those files straight from a bucket, with a CDN in front for speed, HTTPS and a custom domain. There is no server to patch.
Before you start
- An S3-compatible storage account that supports public buckets or website endpoints. See object storage explained.
- A built site folder (e.g.
dist/orpublic/). - A domain and DNS access, and a CDN account.
- A static site cannot run PHP or databases. For WordPress or PHP apps, use web hosting instead.
Create and configure the bucket
- Create a bucket, often named after the site (e.g.
www.example.com). - Enable the static website feature if the provider offers it, with
index.htmlas index and404.htmlas error document. - Allow public read on objects, either through a bucket policy or by letting only the CDN read (preferred when supported).
Upload the site
With rclone (configured as in the rclone guide):
rclone sync ./dist s3backup:www.example.com --checksumOr with the AWS CLI pointed at any S3 endpoint:
aws s3 sync ./dist s3://www.example.com --delete --endpoint-url https://s3.provider.exampleMake sure files get correct Content-Type headers (most tools set them from file extensions).
Add a CDN, domain and HTTPS
- In the CDN, create a site or distribution with the bucket's website endpoint as origin.
- Add your domain and issue a free certificate through the CDN.
- Point DNS: a CNAME for
wwwto the CDN hostname (apex domains need CNAME flattening or ALIAS records). - Set caching: long cache for hashed assets, short cache for
index.html.
See what is a CDN for how caching works.
Single-page apps
Client-side routes (e.g. /dashboard) do not exist as files. Configure the error document or a CDN rewrite to serve index.html for unknown paths.
Automate deploys
In CI, build the site, run the sync command with access keys stored as secrets, then purge the CDN cache for index.html.
Troubleshooting
- 403 AccessDenied: objects are not publicly readable, or the CDN is not authorised.
- Browser downloads HTML instead of showing it: wrong
Content-Type. - Old version still shows: CDN cache; purge or use hashed filenames.
Frequently asked questions
Is static hosting free?
Storage and CDN costs are often very low for small sites, but check request and egress fees.
Can I add a contact form?
Use a third-party form service or a serverless function; see serverless explained.
Can I host a static site on cPanel instead?
Yes, upload the files to public_html with web hosting.
