80 lines
2.4 KiB
Markdown
80 lines
2.4 KiB
Markdown
---
|
|
title: 'Keeping It Simple: Automating Hugo with Gitea'
|
|
date: 2025-03-09
|
|
draft: false
|
|
---
|
|
**So What?**
|
|
Because life is short and repetitive tasks are dull, here's a straightforward setup to automatically update my Hugo-based website every time I push changes to Gitea. No glamor, just practical efficiency.
|
|
|
|
---
|
|
|
|
I've been using Hugo for this site—it's simple, fast, and gets out of the way. Gitea hosts my Git repos because it does exactly what's needed without fuss. Combining these two tools to automate deployments just made sense.
|
|
|
|
Here's the basic workflow:
|
|
|
|
- Write content in Markdown.
|
|
- Commit and push to Gitea.
|
|
- Hugo rebuilds the site automatically.
|
|
|
|
That's it. No magic, no elaborate setups, just two tools working effectively together.
|
|
|
|
#### Automating with Gitea Actions
|
|
|
|
Originally, I considered using a post-receive hook inside Gitea's internal filesystem. But maintaining shell scripts buried in a container volume just felt messy. Instead, I used [Gitea Actions](https://docs.gitea.com/usage/actions) — a cleaner, version-controlled way to define what should happen on push.
|
|
|
|
In my Hugo repo, I created a file at:
|
|
|
|
```
|
|
.gitea/workflows/deploy.yml
|
|
```
|
|
|
|
And dropped this in:
|
|
|
|
```yaml
|
|
name: Build Hugo Site
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
submodules: true
|
|
|
|
- name: Install Hugo
|
|
uses: peaceiris/actions-hugo@v2
|
|
with:
|
|
hugo-version: 'latest'
|
|
extended: true
|
|
|
|
- name: Clear Previous Build Output
|
|
run: rm -rf /mnt/hugo_output/*
|
|
|
|
- name: Build Hugo Site
|
|
run: hugo --minify --destination /mnt/hugo_output --cleanDestinationDir --buildDrafts --buildFuture --buildExpired
|
|
```
|
|
|
|
Gitea picks this up automatically. Every time I push to `main`, it checks out the repo, builds the static site, and syncs the output to my production server.
|
|
|
|
#### The Result
|
|
|
|
Now, pushing changes to the site takes seconds and requires zero manual intervention:
|
|
|
|
- Edit Markdown.
|
|
- Commit and push.
|
|
- Done.
|
|
|
|
Simple, efficient, effective.
|
|
|
|
#### Takeaway
|
|
|
|
Using Hugo and Gitea together isn't groundbreaking, but it is reliably functional—exactly the way I like it. Gitea Actions made it feel tidy and maintainable. If you prefer your tools uncomplicated and effective, this combination might work nicely for you too.
|
|
|