Deploy a Hugo site via Forgejo actions
Using your self-hosted Forgejo server is the absolute best way to keep multiple authors perfectly synchronized.
Because Forgejo is a complete Git forge, you can use standard Git features to handle code collaboration. Even better: by shifting to Forgejo, you can eliminate the need for manual deploy.sh scripts entirely. You can have Forgejo automatically build your Hugo site and sync it to your production server every time an author pushes an update.
Step 1: Syncing Authors via Forgejo (The Git Way)
Instead of passing files back and forth, your authors will interact exclusively with your Forgejo instance.
Create a Repository: Create a new repository on your Forgejo server (e.g., hugo-docs).
Push the Code: Initialize Git in your local Hugo folder and push it to Forgejo:bash git init git remote add origin http://your-forgejo-ip:3000/username/hugo-docs.git git add . git commit -m “Initial commit” git push -u origin main Use code with caution.
Collaboration: Other authors can now simply clone the repository onto their macOS or Linux machines:bash git clone http://your-forgejo-ip:3000/username/hugo-docs.git Use code with caution.
The Daily Workflow: Authors use standard Git rules to stay in sync: • Run git pull before starting work to get the latest edits from others. • Make changes locally, previewing with hugo server. • Run git add ., git commit -m “Added section X”, and git push to upload their work.
Step 2: Automating Deployment via Forgejo Actions
Instead of running a local script on individual laptops, you can leverage Forgejo Actions (built-in CI/CD) to deploy your site automatically.
Ensure you have a Forgejo Runner connected to your instance.
Add your deployment target’s SSH private key into your Forgejo repository under Settings ➔ Actions ➔ Secrets (name it DEPLOY_SSH_KEY).
Create a workflow file in your project path at .forgejo/workflows/deploy.yml: You can automate the build and deployment process by configuring a workflow file (such as the full YAML configuration available in the reference documentation) that triggers whenever code is pushed to the main branch. This workflow uses a Docker runner to check out the code, install Hugo, build the static site, and sync the public directory to your production server via rsync.
Why this approach scales
• No local dependencies: Authors only need Git to collaborate, while Forgejo handles the build process inside an isolated container environment.
• Single source of truth: Git naturally prevents authors from overwriting each other’s work by flagging code conflicts before they hit production.