Deploying a Static Site with Git
Push a static site to your GoZen Host server using Git. Works with Hugo, Astro, Jekyll, or plain HTML.
Static sites are fast, secure, and cheap to run. You build them locally, then push the output to your server. This guide covers deploying to both shared hosting and VPS.
Prerequisites
- A static site generator (Hugo, Astro, Jekyll, or plain HTML)
- Your site built locally (e.g., a
dist/,public/, or_site/folder) - An SSH client or FTP access
On Shared Hosting
Option A: Upload via File Manager
- Build your site locally
- Zip the output folder
- Log into cPanel → File Manager
- Navigate to
public_html/(or your domain’s document root) - Upload the zip
- Extract it
- Make sure
index.htmlis in the root, not inside a subfolder
Option B: SFTP Upload
Use an FTP client like FileZilla:
| Setting | Value |
|---|---|
| Protocol | SFTP (SSH File Transfer Protocol) |
| Host | Your domain or server IP |
| Port | 22 |
| Username | Your cPanel username |
| Password | Your cPanel password |
Upload the contents of your build folder to public_html/.
On a VPS with Git (Recommended)
This is the cleanest workflow: push to Git, and the server pulls and deploys automatically.
Step 1: Set Up the Server
# Install Git and Nginx
sudo apt install git nginx -y
# Create a web root
sudo mkdir -p /var/www/mysite
sudo chown $USER:$USER /var/www/mysite
Step 2: Create a Bare Git Repository
# This is the repository your local machine pushes to
mkdir -p ~/repos/mysite.git
cd ~/repos/mysite.git
git init --bare
Step 3: Add a Post-Receive Hook
This hook automatically deploys your site whenever you push:
nano ~/repos/mysite.git/hooks/post-receive
Add:
#!/bin/bash
GIT_WORK_TREE=/var/www/mysite git checkout -f main
Make it executable:
chmod +x ~/repos/mysite.git/hooks/post-receive
Step 4: Configure Nginx
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
root /var/www/mysite;
index index.html;
location / {
try_files $uri $uri/ =404;
}
# Cache static assets
location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|woff2)$ {
expires 30d;
add_header Cache-Control "public, immutable";
}
}
sudo ln -s /etc/nginx/sites-available/mysite /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
Step 5: Push from Your Local Machine
On your local machine, add the server as a Git remote:
cd your-project
# Build first
npm run build # or hugo, or jekyll build
# Set up the remote
git remote add deploy ssh://deploy@your-server-ip/home/deploy/repos/mysite.git
# Push
git push deploy main
git push deploy main updates it automatically.Build-Then-Push Workflow
For static site generators, the typical workflow is:
- Edit content locally
- Build:
npm run build/hugo/jekyll build - Commit the output folder
- Push:
git push deploy main
Pro tip: Add a build script to your package.json or Makefile that builds and pushes in one command:
#!/bin/bash
npm run build && git add -A && git commit -m "deploy" && git push deploy main
Adding SSL
After your site is live, add HTTPS:
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
Certbot will auto-renew the certificate. Test it:
sudo certbot renew --dry-run
Troubleshooting
| Problem | Fix |
|---|---|
| Push rejected | Make sure you’re pushing to the correct branch (main vs master) |
| 403 Forbidden | Check file permissions: 644 for files, 755 for directories |
| Site shows Nginx default page | Verify the server_name in your Nginx config matches your domain |
| CSS/JS not loading | Check the root path in Nginx and clear browser cache |
| Hook not firing | Verify the hook is executable: chmod +x post-receive |
What to Do Next
- Managing DNS Records: point your domain to the server
- SSL Certificates: HTTPS for your static site
Last updated 05 Apr 2026, 00:00 +0200.