A Forgejo Action to seamlessly set up Hugo for static site builds in CI/CD workflows.
Find a file
Sebastian Schulz 05a6d11ce6
All checks were successful
/ test-version-input-without-file (push) Successful in -9s
/ test-latest-hugo (push) Successful in -8s
/ test-version-input (push) Successful in -8s
/ test-version-file (push) Successful in -7s
/ test-version-file-precedence (push) Successful in -29s
/ test-custom-version-file (push) Successful in -31s
Migrate to devcontainer-features
2026-02-27 18:27:48 +01:00
.forgejo/workflows Fix broken test 2026-02-14 00:06:26 +00:00
.devcontainer.json Migrate to devcontainer-features 2026-02-27 18:27:48 +01:00
action.yaml Remove disable-go feature 2026-02-14 00:00:36 +00:00
LICENSE Initial commit 2026-02-09 11:37:42 +00:00
README.md Remove disable-go feature 2026-02-14 00:00:36 +00:00

setup-hugo

Installs Hugo static site generator for Forgejo CI/CD workflows.

Quick Start

name: Build and Deploy
on:
  push:
    branches: ["main"]

jobs:
  build:
    runs-on: docker
    steps:
      - uses: actions/checkout@v6
      - name: Setup Hugo
        uses: actions/setup-hugo@v1
      - name: Build site
        run: hugo --minify

How It Works

This action installs the Hugo extended edition by determining the desired version (from input, version file, or latest release), downloading the corresponding Linux AMD64 Debian package, and installing it. An installed Go toolchain is beneficial when using Hugo Modules. The default runner of the runner-images repository has Go installed by default.

Inputs

Name Required Description Default
version No Hugo version to install (e.g., 0.120.0). Use latest for the newest stable release. latest
version-file No Path to a file containing the Hugo version (overrides version if file exists). .hugo-version

Note

If both version and an existing version-file are specified, the file takes precedence.

Usage Examples

Example 1: Build with Latest Hugo

name: Build Site
on:
  push:
    branches: ["main"]

jobs:
  build:
    runs-on: docker
    steps:
      - uses: actions/checkout@v6
      - name: Setup Hugo
        uses: actions/setup-hugo@v1
      - name: Build
        run: hugo --minify --destination dist

Example 2: Pin Specific Version

name: Build Site
on:
  push:
    branches: [main]

jobs:
  build:
    runs-on: docker
    steps:
      - uses: actions/checkout@v6
      - name: Setup Hugo 0.120.0
        uses: actions/setup-hugo@v1
        with:
          version: 0.120.0
      - name: Build
        run: hugo --minify

Example 3: Version from Custom File

name: Build Site
on:
  push:
    branches: ["main"]

jobs:
  build:
    runs-on: docker
    steps:
      - uses: actions/checkout@v6
      - name: Setup Hugo
        uses: actions/setup-hugo@v1
        with:
          version-file: .tool-versions
      - name: Build
        run: hugo --minify

Create a custom version file (e.g., .tool-versions) in your repository root:

0.120.0

Note

If using the default .hugo-version file, you can omit the version-file parameter entirely.

Contributing

We welcome contributions! Please follow these steps to contribute:

  1. Fork the repository.
  2. Create a new branch:
    git checkout -b feature-branch
    
  3. Make your changes and commit them:
    git commit -m "Description of your changes"
    
  4. Push to your fork:
    git push origin feature-branch
    
  5. Create a pull request.

Guidelines

  • Follow the existing code style.
  • Write clear and concise commit messages.
  • Ensure your changes do not break existing functionality.
  • Update documentation as needed.

License

This project is licensed under the terms specified in the LICENSE file.