Hugo builds pages in milliseconds, but getting those flat files into production without breaking asset paths or overpaying for managed platforms takes a bit of planning. You don’t need an expensive serverless setup. Stashing your built static files on cheap Hostinger storage and putting StackPath in front of it gives you full control over caching, headers, and edge performance for pennies.
Most static hosts funnel you into serverless tiers with rigid bandwidth caps or surprise overage bills. By pairing shared hosting storage with an enterprise CDN, you bypass those headaches while keeping raw control over your origin server and caching behavior.

The Architecture: Static Files at the Edge
The pipeline separates generation, origin storage, edge caching, and DNS into four distinct pieces:
- Hugo: Compiles Markdown, layouts, and static assets locally into plain HTML, CSS, and JS inside your
public/folder. - Hostinger: Acts as our flat-file origin. LiteSpeed serves your files straight out of
public_html. - StackPath: Terminates incoming HTTPS connections, caches your assets at the edge, and only hits Hostinger on a cache miss.
- Namecheap: Manages DNS, pointing your apex domain and subdomains to StackPath’s edge IPs.
If you’ve already walked through our guide on how to connect Namecheap domain to Hostinger with StackPath CDN and end-to-end SSL, the DNS and edge setup will look familiar. The difference here is that we skip PHP, MySQL, and dynamic runtimes completely—LiteSpeed just serves static files at zero CPU overhead.
Step 1: Configure and Build Hugo for Production
Before running your build, double-check your base URL. If this doesn’t match your live domain exactly, your CSS, JS bundles, and canonical tags will break the second traffic routes through the CDN.
Open hugo.toml (or config.toml) and verify the production values:
baseURL = "https://example.com/"
languageCode = "en-us"
title = "My Static Production Site"
theme = "clean-terminal" [outputs] home = ["HTML", "RSS", "JSON"] [minify] minifyOutput = true [build] writeStats = trueHugo handles minification right out of the box. If you run custom pipelines like Hugo Pipes with Tailwind or PostCSS, consult the Hugo documentation before building.
Run the build command locally or in CI to generate your minified assets:
hugo --minify --gc --cleanDestinationDirI always include --gc to clear out unused cached assets from previous runs, and --cleanDestinationDir to wipe public/ before building fresh files. Take a quick look inside public/ to confirm your index.html and asset directories are sitting there.
Step 2: Prepare Hostinger hPanel for Flat Files
Hostinger runs LiteSpeed under the hood on its shared hosting tiers, which makes it a surprisingly fast, low-cost origin for static content.
- Log in to hPanel and go to Websites.
- Pick your domain and open the File Manager (or enable SSH under Advanced > SSH Access).
- Head into
public_htmland delete default placeholder junk likedefault.php.
To control browser caching, handle 404s, and set proper cache-control headers before StackPath caches them, drop an .htaccess file right into public_html:
# Disable directory listing
Options -Indexes
# Custom Error Pages
ErrorDocument 404 /404.html
# Enable Gzip / Deflate
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript application/json
# Set static asset caching headers for origin responses
ExpiresActive On
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType text/html "access plus 1 hour"
Setting long cache lifetimes on fingerprinted CSS, JS, and image files lets both StackPath and the visitor’s browser treat those assets as immutable. Check out the MDN Cache-Control documentation if you want to fine-tune these directives.
Step 3: Upload Static Assets to Hostinger
You can upload files via SFTP or the hPanel File Manager, but rsync over SSH is vastly faster for repeated deploys. Make sure you upload the contents of public/, not the folder itself. You want public_html/index.html, not public_html/public/index.html.
From your local project root, sync your build:
rsync -avz --delete -e "ssh -p 65002" public/ u123456789@srv123.main-hosting.eu:public_html/Hostinger usually runs SSH on custom port 65002—check your hPanel SSH Access page to grab your specific port, username, and IP. The trailing slash on public/ is critical; omit it, and rsync creates a nested folder on the server.
Step 4: Configure the Origin in StackPath CDN
StackPath will sit in front of Hostinger, intercepting traffic and serving cached static assets from its edge nodes.
- Log in to StackPath and click Create Site.
- Select CDN as your service.
- Enter your root domain (e.g.,
example.com). - Fill in the Origin Details:
- Origin Type: IP Address.
- Origin IP: Your Hostinger server IP (find this in hPanel under Hosting Details).
- Origin Port: 443.
- Host Header: Set this explicitly to your domain name (e.g.,
example.com). If you leave this blank, LiteSpeed won’t know which vhost to route to and will return a default server page or 404.
Make sure an SSL certificate is already installed on Hostinger (via Let’s Encrypt in hPanel) before picking port 443. This keeps traffic encrypted between StackPath’s edge and your Hostinger origin.
If you run into issues with self-hosted fonts failing to render after the CDN is active, see our tutorial on how to fix CORS errors on web fonts and static assets in StackPath CDN.
Step 5: Route DNS in Namecheap
Now that StackPath knows where your Hostinger origin is, you need to point your actual domain at StackPath.
- Log in to Namecheap, go to your Domain List, and hit Manage.
- Make sure your nameservers are set to Namecheap BasicDNS.
- Click the Advanced DNS tab.
- Delete any old A or CNAME records pointing straight to Hostinger.
- Add an A Record for
@pointing to the Edge IP StackPath gave you. - Add a CNAME Record for
wwwpointing to your StackPath CDN host alias (likesite.stackpathcdn.com).
If you’re weighing ALIAS versus raw A records on the apex domain, read through our guide on A Record vs CNAME for root domain in Namecheap DNS.
Once saved, test resolution using dig:
dig +short example.com @8.8.8.8You should see StackPath’s anycast IPs in the response, not your Hostinger origin IP.
Step 6: Handle Hugo Trailing Slashes and Cache Invalidation
Hugo generates URLs using directories with index files (e.g., /blog/post-1/index.html). If a user hits /blog/post-1 without the trailing slash, LiteSpeed might try to redirect them, while StackPath might try to serve it directly. That mismatch can easily cause an infinite 301 redirect loop.
To keep behavior consistent, enforce trailing slashes for directories inside your .htaccess file:
RewriteEngine On
RewriteBase / # Force HTTPS behind CDN
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Ensure trailing slash on directories to prevent edge loops
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !/$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1/ [L,R=301]When you push content changes, unchanged CSS and JS files stay cached at the edge. To force StackPath to drop cached HTML pages after an update, purge them through the StackPath dashboard (CDN > Purge Cache) or hit their API directly:
curl -X POST "https://gateway.stackpath.com/cdn/v1/stacks/{stack_id}/sites/{site_id}/purge" -H "Authorization: Bearer YOUR_API_TOKEN" -H "Content-Type: application/json" -d '{"items": ["/index.html", "/blog/*"]}'Step 7: Automate Deployment with GitHub Actions
Manual rsync uploads work fine while setting things up, but you don’t want to run terminal commands every time you fix a typo. You can automate the entire build-and-deploy pipeline using GitHub Actions.
Create .github/workflows/deploy.yml in your repository:
name: Deploy Hugo to Hostinger on: push: branches: - main jobs: deploy: runs-on: ubuntu-latest steps: - name: Checkout Repository uses: actions/checkout@v4 with: submodules: true fetch-depth: 0 - name: Setup Hugo uses: peaceiris/actions-hugo@v2 with: hugo-version: '0.124.0' extended: true - name: Build Hugo Site run: hugo --minify --gc - name: Sync Files to Hostinger uses: easingthemes/ssh-deploy@v5.0.3 with: SSH_PRIVATE_KEY: ${{ secrets.HOSTINGER_SSH_KEY }} ARGS: "-rltgoDzvO --delete" SOURCE: "public/" REMOTE_HOST: ${{ secrets.HOSTINGER_HOST }} REMOTE_USER: ${{ secrets.HOSTINGER_USER }} REMOTE_PORT: "65002" TARGET: "public_html/"Under your GitHub repo’s Settings > Secrets and variables > Actions, add HOSTINGER_SSH_KEY, HOSTINGER_HOST, and HOSTINGER_USER. Now, every push to main compiles your site in an Ubuntu runner and syncs the exact diff to Hostinger.
Frequently Asked Questions
Can I deploy Hugo directly from Hostinger Git integration?
No. Hostinger’s built-in Git deployment simply clones your repository into public_html. Shared hosting servers don’t have the Go runtime or the Hugo binary installed, so they can’t execute hugo build. You need to build locally or use GitHub Actions to push the compiled public/ output.
Why does StackPath return a 502 Bad Gateway error?
A 502 means StackPath couldn’t talk to Hostinger. The three most common causes: your origin IP in StackPath is incorrect, the Host Header in StackPath doesn’t match the exact domain configured in hPanel, or you chose origin port 443 without having an active SSL certificate installed on Hostinger.
Do I need an SSL certificate on Hostinger if StackPath provides edge SSL?
Yes. While StackPath can terminate public SSL at the edge and connect to Hostinger over plain HTTP (port 80), doing that leaves traffic between the CDN edge and your origin unencrypted. Installing a free Let’s Encrypt certificate in hPanel allows strict end-to-end SSL over port 443.
How do I test my origin server before changing DNS records in Namecheap?
Edit your local hosts file. Add a line mapping your Hostinger server IP directly to your domain name. This forces your local browser to bypass public DNS and hit Hostinger directly, so you can confirm your pages and assets load cleanly before changing any live records.
Next Steps with Edge Routing
With Hugo generating flat files on Hostinger and StackPath handling edge caching, your site will load almost instantaneously while costing virtually nothing to run. If you want to compare how another static framework handles this exact stack, check out our guide on how to deploy an Astro static site on Hostinger with Namecheap DNS and StackPath CDN.

