The up-to-date Hugo docker images

I used to use the klakegg/hugo image, but it’s been a while since it was updated, so I created an up-to-date Hugo docker image for meeting my site’s requirements (>=0.110.0), hope this image helps.

I set up a schedule (run every 30 min) workflow for checking and building the latest Hugo docker image as well, the images will be always keeping update.

Hugo Docker Images

Docker Pulls
Docker Image Version (tag latest semver)
Check and Build Latest Image

The up to date Hugo docker images.

There are two ways to check and build latest Hugo images.

  1. Waiting for the cron job (runs every 30 min).
  2. Trigger the job immediately by commenting on the issue.

Images

Image Size Extended Go Node NPM Git
latest, <version> Docker Image Size (tag) :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark:
base, base-<version> Docker Image Size (tag) :white_check_mark: :x: :x: :x: :x:
go, go-<version> Docker Image Size (tag) :white_check_mark: :white_check_mark: :x: :x: :x:
node, node-<version> Docker Image Size (tag) :white_check_mark: :x: :white_check_mark: :white_check_mark: :x:
exts, exts-<version> Docker Image Size (tag) :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark:
reg, reg-<version> Docker Image Size (tag) :x: :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark:
reg-base, reg-base-<version> Docker Image Size (tag) :x: :x: :x: :x: :x:
reg-go, reg-go-<version> Docker Image Size (tag) :x: :white_check_mark: :x: :x: :x:
reg-node, reg-node-<version> Docker Image Size (tag) :x: :x: :white_check_mark: :white_check_mark: :x:
reg-exts, reg-exts-<version> Docker Image Size (tag) :x: :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark:
  • <version>: the placeholder for Hugo version, i.e. 0.111.3.
  • reg: represents the regular Hugo version.
  • exts: the exts includes not only the tools listed above, but also Dart Sass Embedded, PostCSS CLI, Autoprefixer, PurgeCSS and RTLCSS.

Usage

Let’s take razonyang/hugo image as an example.

$ docker pull razonyang/hugo

Start Hugo Server

$ docker run -p 1313:1313 \
  -v ${PWD}:/src \
  razonyang/hugo \
  hugo server --bind 0.0.0.0

Note that --bind 0.0.0.0 is required.

Using another port than 1313, such as 8080.

$ docker run -p 8080:8080 \
  -v ${PWD}:/src \
  razonyang/hugo \
  hugo server --bind 0.0.0.0 -p 8080

Build Site

The example uses Nginx as web server to serve Hugo generated static files.

Firstly, create the Dockerfile file on your site root.

###############
# Build Stage #
###############
FROM razonyang/hugo:exts as builder
# Base URL
ARG HUGO_BASEURL=
ENV HUGO_BASEURL=${HUGO_BASEURL}
# Build site
COPY . /src
RUN hugo --minify --gc --enableGitInfo
# Set the fallback 404 page if defaultContentLanguageInSubdir is enabled, please replace the `en` with your default language code.
# RUN cp ./public/en/404.html ./public/404.html

###############
# Final Stage #
###############
FROM razonyang/hugo:nginx
COPY --from=builder /src/public /site
docker build -t user/my-site .

You may want to check the built image.

docker build -t user/my-site --build-arg HUGO_BASEURL=http://localhost:8080 .
docker run -p 8080:80 user/my-site

Now the built site can be previewed on http://localhost:8080/.

7 Likes

Thank you very much!

@bep or @jmooring Can we make this the default docker image to link to in the docs? The previous one is outdated and if you look at github he is also not responding very well in the past and no activity since last year :confused: GitHub - klakegg/docker-hugo: Truly minimal Docker images for Hugo open-source static site generator.

1 Like

FYI, the image name was renamed from razonyang/hugo to hugomods/hugo two days ago. To be clarified, it isn’t maintained by the Official team.

Latest docs: Hugo Docker Images - Docs - Hugo Modules.

2 Likes

Thanks for the image <3

1 Like

The docs is out-of-date, because I couldn’t edit the post anymore, please check the latest docs
out on https://docker.hugomods.com/.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.