Static websites are just HTML, CSS, JavaScript and images, with no database or PHP. They are fast, secure and cheap to run. Whether you write HTML by hand or use a generator such as Hugo, Jekyll, Eleventy or Astro, hosting the result on cPanel is simple: upload the built files to your document root.
Before you start
- A domain on your cPanel account. Its document root is shown in cPanel → Domains → Domains (
public_htmlfor the primary domain). - For generators: build on your own computer. The build output folder is usually
public(Hugo),_site(Jekyll, Eleventy) ordist(Astro, Vite).
Build the site
| Tool | Build command | Output |
|---|---|---|
| Hugo | hugo --minify | public/ |
| Jekyll | bundle exec jekyll build | _site/ |
| Eleventy | npx @11ty/eleventy | _site/ |
| Astro | npm run build | dist/ |
Set the site's base URL to your real domain (for example baseURL = "https://example.com/" in Hugo) before building, so links work on the server.
Upload the files
- Compress the contents of the output folder into a ZIP (not the folder itself).
- Open cPanel → Files → File Manager, go to
public_html, and remove old placeholder files such as the defaultindex.htmlif needed. - Click Upload, upload the ZIP, then right-click it → Extract. Delete the ZIP afterwards.
- Open your domain.
index.htmlin the root is served as the home page.
For frequent updates, FileZilla or Git deployment is faster than ZIP uploads.
Clean URLs, caching and HTTPS
Most generators create about/index.html, so /about/ works automatically. For hand-written about.html files, add this to public_html/.htaccess to serve /about without the extension:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+?)/?$ $1.html [L]Let browsers cache static assets for a long time:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
</IfModule>Generators add hashes to asset file names, so long caching is safe. Turn on Force HTTPS and compression with Optimize Website.
Tip: A custom 404 page from your generator (e.g. 404.html) can be activated with ErrorDocument 404 /404.html. See custom error pages.
Automate deployment with Git
Commit the built output (or build in CI and push to a deploy branch), clone it with cPanel Git Version Control, and use a .cpanel.yml that copies files into public_html. Details in Git Version Control.
Troubleshooting
- Unstyled pages or broken links: wrong base URL in the build config.
- 403 Forbidden: files were extracted into a subfolder, so
public_htmlhas noindex.html. - Old version shows: browser or LiteSpeed cache; open a private window.
