This guide helps you set up Netlify deployment with GitHub Actions.
- GitHub repository with the Hugo site
- Netlify account (free at https://netlify.com)
- Go to https://app.netlify.com
- Click "Add new site" → "Import an existing project"
- Connect to GitHub and select this repository
- Important: In build settings, you can leave defaults or set:
- Build command:
echo 'Build happens in GitHub Actions' - Publish directory:
public
- Build command:
- Click "Deploy site"
- Wait for the initial deploy (it will fail or be empty - that's OK)
- In your Netlify site dashboard, go to "Site configuration" → "General"
- Under "Site information", copy the Site ID (looks like:
abc123def-4567-89gh-ijkl-mnopqrstuvwx)
- Go to https://app.netlify.com/user/applications
- Click "New access token"
- Give it a name like "GitHub Actions Deploy"
- Click "Generate token"
- Copy the token immediately (you won't see it again)
-
Go to your GitHub repository
-
Navigate to Settings → Secrets and variables → Actions
-
Click "New repository secret"
-
Add two secrets:
Secret 1:
- Name:
NETLIFY_AUTH_TOKEN - Value: [paste your Netlify personal access token]
Secret 2:
- Name:
NETLIFY_SITE_ID - Value: [paste your Netlify site ID]
- Name:
- Go to your repository Settings → Actions → General
- Ensure "Allow all actions and reusable workflows" is selected
- Save if you made changes
Once the secrets are added, you can trigger a deployment by:
- Pushing to the
mainbranch - Opening a pull request (creates a preview deployment)
- Manually running the workflow in Actions tab
- Push to main: Deploys to production at your Netlify site URL
- Pull requests from a branch on this repo: Creates a unique preview URL and posts it as a comment on the PR
- Pull requests from a fork: Don't auto-deploy (fork workflows run with a read-only token and no access to secrets). A member can comment
/deploy-previewon the PR to trigger a preview build. - Manual trigger: Can manually deploy from the Actions tab
- Make sure you've added the secret correctly in GitHub Settings
- Secret names are case-sensitive
- Check that
hugo --minifybuilds successfully locally - Verify
public/directory contains the built site
- Check that
enable-pull-request-comment: trueis set in the workflow - Ensure GitHub Actions has permission to comment on PRs
To test the build process locally:
# Install dependencies
npm ci
# Build Tailwind CSS
npm run build-tailwind
# Build Hugo site
hugo --minify
# Check the public/ directory
ls -la public/To use a custom domain:
- Go to your Netlify site dashboard
- Navigate to "Domain management"
- Click "Add custom domain"
- Follow Netlify's instructions for DNS configuration
- Update
baseURLinhugo.tomlto your custom domain