cPanel

Host a static website (HTML, Hugo, Jekyll, Astro) on cPanel

Publish a static website on cPanel hosting: build it locally, upload the output folder to the document root, set clean URLs, caching headers and HTTPS, and automate with Git.

BeginnercPanel hosting2 min read

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_html for the primary domain).
  • For generators: build on your own computer. The build output folder is usually public (Hugo), _site (Jekyll, Eleventy) or dist (Astro, Vite).

Build the site

ToolBuild commandOutput
Hugohugo --minifypublic/
Jekyllbundle exec jekyll build_site/
Eleventynpx @11ty/eleventy_site/
Astronpm run builddist/

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

  1. Compress the contents of the output folder into a ZIP (not the folder itself).
  2. Open cPanel → Files → File Manager, go to public_html, and remove old placeholder files such as the default index.html if needed.
  3. Click Upload, upload the ZIP, then right-click it → Extract. Delete the ZIP afterwards.
  4. Open your domain. index.html in 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_html has no index.html.
  • Old version shows: browser or LiteSpeed cache; open a private window.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.