• Stars
    star
    1,217
  • Rank 38,518 (Top 0.8 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

GitHub Actions for Hugo ⚡️ Setup Hugo quickly and build your site fast. Hugo extended, Hugo Modules, Linux (Ubuntu), macOS, and Windows are supported.

GitHub Actions for Hugo

GitHub Actions for Hugo

license release GitHub release date Release Feed Test Code Scanning

CodeFactor codecov Maintainability

This Hugo Setup Action can install Hugo to a virtual machine of GitHub Actions. Hugo extended version, Hugo Modules, Linux (Ubuntu), macOS, and Windows are supported.

From v2, this Hugo Setup Action has migrated to a JavaScript (TypeScript) action. We no longer build or pull a Hugo docker image. Thanks to this change, we can complete this action in less than a few seconds. (A docker base action was taking about 1 min or more execution time to build and pull a docker image.)

OS (runs-on) ubuntu-latest, ubuntu-20.04, ubuntu-22.04 macos-latest windows-2019
Support ✅️ ✅️ ✅️
Hugo type Hugo Extended Hugo Modules Latest Hugo
Support ✅️ ✅️ ✅️

Table of Contents

Getting started

⭐️ Create your workflow

An example workflow .github/workflows/gh-pages.yml with GitHub Actions for GitHub Pages. For the first deployment, we have to do this operation: First Deployment with GITHUB_TOKEN - peaceiris/actions-gh-pages

peaceiris/actions-gh-pages - GitHub

name: GitHub Pages

on:
  push:
    branches:
      - main  # Set a branch to deploy
  pull_request:

jobs:
  deploy:
    runs-on: ubuntu-22.04
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: true  # Fetch Hugo themes (true OR recursive)
          fetch-depth: 0    # Fetch all history for .GitInfo and .Lastmod

      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: '0.110.0'
          # extended: true

      - name: Build
        run: hugo --minify

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        if: github.ref == 'refs/heads/main'
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./public

Options

⭐️ Use Hugo extended

Set extended: true to use a Hugo extended version.

- name: Setup Hugo
  uses: peaceiris/actions-hugo@v2
  with:
    hugo-version: '0.110.0'
    extended: true

⭐️ Use the latest version of Hugo

Set hugo-version: 'latest' to use the latest version of Hugo.

- name: Setup Hugo
  uses: peaceiris/actions-hugo@v2
  with:
    hugo-version: 'latest'

This action fetches the latest version of Hugo by hugo | Homebrew Formulae

Tips

⭐️ Caching Hugo Modules

Insert a cache step before site-building as follows. Note that the cache dir location of Hugo on a Linux-based operating system is /tmp/hugo_cache. On macOS, ${TMPDIR}/hugo_cache has the location.

- uses: actions/cache@v2
  with:
    path: /tmp/hugo_cache
    key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }}
    restore-keys: |
      ${{ runner.os }}-hugomod-

- name: Build
  run: hugo --minify

⭐️ Read Hugo version from file

How to sync a Hugo version between a Docker Compose and a GitHub Actions workflow via .env file.

Write a HUGO_VERSION to the .env file like the following and push it to a remote branch.

HUGO_VERSION=0.110.0

Next, add a step to read a Hugo version from the .env file.

    - name: Read .env
      id: hugo-version
      run: |
        . ./.env
        echo "HUGO_VERSION=${HUGO_VERSION}" >> "${GITHUB_OUTPUT}"

    - name: Setup Hugo
      uses: peaceiris/actions-hugo@v2
      with:
        hugo-version: '${{ steps.hugo-version.outputs.HUGO_VERSION }}'
        extended: true

Here is a docker-compose.yml example.

version: '3'

services:
  hugo:
    container_name: hugo
    image: "peaceiris/hugo:v${HUGO_VERSION}"
    # image: peaceiris/hugo:v${HUGO_VERSION}-mod   # Hugo Modules
    # image: peaceiris/hugo:v${HUGO_VERSION}-full  # Hugo Modules and Node.js
    ports:
      - 1313:1313
    volumes:
      - ${PWD}:/src
    command:
      - server
      - --bind=0.0.0.0
      - --buildDrafts

The alpine base Hugo Docker image is provided on the following repository.

peaceiris/hugo-extended-docker: Hugo alpine base Docker image (Hugo extended and Hugo Modules)

⭐️ Workflow for autoprefixer and postcss-cli

Here is an example workflow for the google/docsy Hugo theme. This theme needs autoprefixer and postcss-cli to build a project. The following workflow is tested with google/docsy-example.

A workflow for the Hugo Babel pipeline is also the same as follows.

name: GitHub Pages

on:
  push:
    branches:
      - master  # Set a branch to deploy
  pull_request:

jobs:
  deploy:
    runs-on: ubuntu-22.04
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0         # Fetch all history for .GitInfo and .Lastmod

      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: '0.110.0'
          extended: true

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: '18'
          cache: 'npm'
          # The action defaults to search for the dependency file (package-lock.json,
          # npm-shrinkwrap.json or yarn.lock) in the repository root, and uses its
          # hash as a part of the cache key.
          # https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-data
          cache-dependency-path: '**/package-lock.json'

      - run: npm ci
      - run: hugo --minify

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        if: github.ref == 'refs/heads/master'
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}

⭐️ Workflow for asciidoctor

Here is an example workflow for a Hugo project using asciidoctor.

name: GitHub Pages

on:
  push:
    branches:
      - main  # Set a branch to deploy
  pull_request:

jobs:
  deploy:
    runs-on: ubuntu-22.04
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: true  # Fetch Hugo themes (true OR recursive)
          fetch-depth: 0    # Fetch all history for .GitInfo and .Lastmod

      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: '0.110.0'
          extended: true

      - name: Setup Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: 3.2

      - run: gem install asciidoctor

      - name: Run Hugo
        run: |
          alias asciidoctor="asciidoctor --attribute=experimental=true --attribute=icons=font"
          hugo --minify

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        if: github.ref == 'refs/heads/main'
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}

⭐️ Non-ascii Filename

cf. Gitinfo fails on unicode filename · Issue #3071 · gohugoio/hugo

name: GitHub Pages

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-22.04
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Disable quotePath
        run: git config core.quotePath false

      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: '0.110.0'

CHANGELOG

License

About Maintainer

Maintainer Notes

Run npm test on a Docker container.

# On container
make build
make all

# Release script on host
./release.sh

More Repositories

1

actions-gh-pages

GitHub Actions for GitHub Pages 🚀 Deploy static files and publish your site easily. Static-Site-Generators-friendly.
TypeScript
3,940
star
2

emoji-ime-dictionary

日本語で絵文字入力をするための IME 追加辞書 📙 Google 日本語入力などで日本語から絵文字への変換を可能にする IME 拡張辞書
Python
296
star
3

actions-mdbook

GitHub Actions for mdBook (rust-lang/mdBook) ⚡️ Setup mdBook quickly and build your site fast. Linux (Ubuntu), macOS, and Windows are supported.
TypeScript
249
star
4

mkdocs-material-boilerplate

MkDocs Material Boilerplate (Starter Kit) - Deploy documentation to hosting platforms (Netlify, GitHub Pages, GitLab Pages, and AWS Amplify Console) with Docker, pipenv, and GitHub Actions.
Python
98
star
5

actions-label-commenter

Label Commenter Action: Label triggered GitHub Action for posting a template comment, and automatically open/close/lock/unlock issues, pull-requests, and discussions.
TypeScript
79
star
6

google-ime-dictionary

日英変換・英語略語展開のための IME 追加辞書 📙 日本語から英語への和英変換や英語略語の展開を Google 日本語入力や ATOK などで可能にする IME 拡張辞書
Shell
65
star
7

hugo-theme-iris

Hugo IRIS Theme - Portfolio and Blog
HTML
60
star
8

hugo-extended-docker

Debian Based Docker Image for Hugo (Hugo extended and Hugo Modules)
Makefile
51
star
9

docker-mdbook

mdBook Alpine Base Docker Image.
Dockerfile
31
star
10

actions-suggest-related-links

A GitHub Action to suggest related or similar issues, documents, and links. Based on the power of NLP and fastText.
TypeScript
29
star
11

actions-github-pages

The v3 implementation of GitHub Actions for GitHub Pages.
TypeScript
12
star
12

actions-pixela

GitHub Actions for Pixela (a-know/pi) - a-know/pi Setup Action. Linux (Ubuntu), macOS, and Windows are supported.
TypeScript
12
star
13

actions-self-hosted-runners

GitHub Actions self-hosted runner on VirtualBox with Vagrant.
Shell
10
star
14

actions-broken-link-checker

GitHub Actions for broken-link-checker (Find broken links, missing images, etc in your HTML)
Dockerfile
8
star
15

actions-pipenv

GitHub Actions for Python project with pipenv
Dockerfile
6
star
16

actions-hugo-link-check

GitHub Actions to check broken links for Hugo
Dockerfile
5
star
17

hugo-mod-bulma

Bulma packaged as a Hugo Module.
5
star
18

hugo-mod-mermaidjs

mermaid-js/mermaid packaged as a Hugo Module.
4
star
19

hugo-mod-mathjax

MathJax packaged as a Hugo Module.
4
star
20

hugo-mod-revealjs

reveal.js packaged as a Hugo Module.
3
star
21

actions-mkdocs-gh-pages

GitHub Actions for MkDocs and GitHub Pages - Build markdown documentation with Material for MkDocs and deploy to GitHub Pages automatically
Shell
3
star
22

docker-latex

Docker image for LaTeX
Dockerfile
3
star
23

actions-muffet

GitHub Actions for muffet (Fast website link checker in Go)
Dockerfile
3
star
24

actions-liche

GitHub Actions for liche (Fast Link Checker for Markdown and HTML in Go)
Dockerfile
3
star
25

peaceiris

About peaceiris
2
star
26

actions-export-envs

Exporting ACTIONS_RUNTIME_TOKEN and ACTIONS_CACHE_URL to enable the Docker layer caching on GitHub Actions.
Shell
2
star
27

mlops

MLOps and DevOps Playground
2
star
28

Hatena-Intern-2020

Go
1
star
29

actions-utils

Utilities for the GitHub Actions.
JavaScript
1
star
30

test-sphinx

Python
1
star
31

actions-github-app-token

A GitHub Action to generate a token for GitHub Apps
TypeScript
1
star
32

test-hugo-external-repo

Test repo: Deploy from https://github.com/peaceiris/hugo-test-project
HTML
1
star
33

test-docusaurus

GitHub Pages and GitHub Actions example for facebook/docusaurus https://test-docusaurus.peaceiris.com/
JavaScript
1
star
34

gatsby-test

Log: https://github.com/peaceiris/gatsby-test/commits/gh-pages
JavaScript
1
star
35

netlify-search-function

Go
1
star
36

contents

Blog contents
1
star
37

investigate-hugo-hanging

A repository to investigate a hanging of Hugo on GitHub Actions
HTML
1
star
38

test-mdbook

https://github.com/peaceiris/test-mdbook/tree/gh-pages
Shell
1
star