Skip to content

Commit 6d89b4d

Browse files
committed
Document usage of official Docker image
1 parent 2ec625a commit 6d89b4d

File tree

4 files changed

+133
-12
lines changed

4 files changed

+133
-12
lines changed

content/en/installation/bsd.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ weight: 40
1616

1717
Most BSD derivatives maintain a repository for commonly installed applications. Please note that these repositories may not contain the [latest release].
1818

19-
[latest release]: https://github.com/gohugoio/hugo/releases/latest
20-
2119
### DragonFly BSD
2220

2321
[DragonFly BSD] includes Hugo in its package repository. To install the extended edition of Hugo:
@@ -26,8 +24,6 @@ Most BSD derivatives maintain a repository for commonly installed applications.
2624
sudo pkg install gohugo
2725
```
2826

29-
[DragonFly BSD]: https://www.dragonflybsd.org/
30-
3127
### FreeBSD
3228

3329
[FreeBSD] includes Hugo in its package repository. To install the extended edition of Hugo:
@@ -36,8 +32,6 @@ sudo pkg install gohugo
3632
sudo pkg install gohugo
3733
```
3834

39-
[FreeBSD]: https://www.freebsd.org/
40-
4135
### NetBSD
4236

4337
[NetBSD] includes Hugo in its package repository. To install the extended edition of Hugo:
@@ -46,8 +40,6 @@ sudo pkg install gohugo
4640
sudo pkgin install go-hugo
4741
```
4842

49-
[NetBSD]: https://www.netbsd.org/
50-
5143
### OpenBSD
5244

5345
[OpenBSD] includes Hugo in its package repository. This will prompt you to select which edition of Hugo to install:
@@ -56,8 +48,6 @@ sudo pkgin install go-hugo
5648
doas pkg_add hugo
5749
```
5850

59-
[OpenBSD]: https://www.openbsd.org/
60-
6151
{{% include "/_common/installation/04-build-from-source.md" %}}
6252

6353
## Comparison

content/en/installation/linux.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,46 @@ sudo xbps-install -S hugo
172172

173173
{{% include "/_common/installation/04-build-from-source.md" %}}
174174

175+
## Docker container
176+
177+
### Prerequisites {#docker-prerequisites}
178+
179+
Before running the Docker container locally you must install Docker Desktop or Docker Engine. See the installation instructions for either [Docker Desktop] or [Docker Engine].
180+
181+
When building your production site in a [CI/CD](g) workflow, whether you can run the Docker container depends on the service provider. For example, GitHub Pages and GitLab Pages allow you to run the Docker container.
182+
183+
To prevent ownership and permission problems, create the Hugo [cache directory](#cache-directory) and ignore the error if the directory already exists:
184+
185+
```text
186+
mkdir -p $HOME/.cache/hugo_cache
187+
```
188+
189+
### Commands
190+
191+
To build your site using the latest version:
192+
193+
```sh {copy=true}
194+
docker run --rm -v .:/project -v $HOME/.cache/hugo_cache:/cache ghcr.io/gohugoio/hugo:latest build
195+
```
196+
197+
To build your site and start the embedded web server using the latest version:
198+
199+
```sh {copy=true}
200+
docker run --rm -v .:/project -v $HOME/.cache/hugo_cache:/cache -p 1313:1313 ghcr.io/gohugoio/hugo:latest server --bind="0.0.0.0"
201+
```
202+
203+
To use a specific version, in the commands above replace `latest` with any of the [tagged image versions]. For example, to build your site using v0.136.1:
204+
205+
```sh {copy=true}
206+
docker run --rm -v .:/project -v $HOME/.cache/hugo_cache:/cache ghcr.io/gohugoio/hugo:v0.136.1 build
207+
```
208+
209+
### Cache directory
210+
211+
Attaching the host's Hugo cache directory to the container can significantly enhance performance, particularly for large and image-heavy sites. This allows Hugo to reuse previously generated content, reducing the need for repeated processing and transpilation.
212+
213+
If you are using a custom Hugo cache directory, in the commands above replace `$HOME/.cache/hugo_cache` with the absolute path to your cache directory.
214+
175215
## Comparison
176216

177217
 |Prebuilt binaries|Package managers|Repository packages|Build from source
@@ -190,6 +230,8 @@ Latest version available?|:heavy_check_mark:|:heavy_check_mark:|varies|:heavy_ch
190230
[Calculate Linux]: https://www.calculate-linux.org/
191231
[CentOS]: https://www.centos.org/
192232
[Debian]: https://www.debian.org/
233+
[Docker Desktop]: https://docs.docker.com/desktop/setup/install/linux/
234+
[Docker Engine]: https://docs.docker.com/engine/install/
193235
[elementary OS]: https://elementary.io/
194236
[EndeavourOS]: https://endeavouros.com/
195237
[Exherbo]: https://www.exherbolinux.org/
@@ -210,6 +252,7 @@ Latest version available?|:heavy_check_mark:|:heavy_check_mark:|varies|:heavy_ch
210252
[Pop!_OS]: https://pop.system76.com/
211253
[Red Hat Enterprise Linux]: https://www.redhat.com/
212254
[Solus]: https://getsol.us/
255+
[tagged image versions]: https://github.com/gohugoio/hugo/pkgs/container/hugo/versions?filters%5Bversion_type%5D=tagged
213256
[Ubuntu]: https://ubuntu.com/
214257
[USE]: https://packages.gentoo.org/packages/www-apps/hugo
215258
[Void Linux]: https://voidlinux.org/

content/en/installation/macos.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,48 @@ weight: 10
2424
sudo port install hugo
2525
```
2626

27-
[MacPorts]: https://www.macports.org/
28-
2927
{{% include "/_common/installation/04-build-from-source.md" %}}
3028

29+
## Docker container
30+
31+
### Prerequisites {#docker-prerequisites}
32+
33+
Before running the Docker container locally you must install Docker Desktop. See the [installation instructions].
34+
35+
When building your production site in a [CI/CD](g) workflow, whether you can run the Docker container depends on the service provider. For example, GitHub Pages and GitLab Pages allow you to run the Docker container.
36+
37+
To prevent ownership and permission problems, create the Hugo [cache directory](#cache-directory) and ignore the error if the directory already exists:
38+
39+
```text
40+
mkdir -p $HOME/Library/Caches/hugo_cache
41+
```
42+
43+
### Commands
44+
45+
To build your site using the latest version:
46+
47+
```sh {copy=true}
48+
docker run --rm -v .:/project -v $HOME/Library/Caches/hugo_cache:/cache ghcr.io/gohugoio/hugo:latest build
49+
```
50+
51+
To build your site and start the embedded web server using the latest version:
52+
53+
```sh {copy=true}
54+
docker run --rm -v .:/project -v $HOME/Library/Caches/hugo_cache:/cache -p 1313:1313 ghcr.io/gohugoio/hugo:latest server --bind="0.0.0.0"
55+
```
56+
57+
To use a specific version, in the commands above replace `latest` with any of the [tagged image versions]. For example, to build your site using v0.136.1:
58+
59+
```sh {copy=true}
60+
docker run --rm -v .:/project -v $HOME/Library/Caches/hugo_cache:/cache ghcr.io/gohugoio/hugo:v0.136.1 build
61+
```
62+
63+
### Cache directory
64+
65+
Attaching the host's Hugo cache directory to the container can significantly enhance performance, particularly for large and image-heavy sites. This allows Hugo to reuse previously generated content, reducing the need for repeated processing and transpilation.
66+
67+
If you are using a custom Hugo cache directory, in the commands above replace `$HOME/Library/Caches/hugo_cache` with the absolute path to your cache directory.
68+
3169
## Comparison
3270

3371
 |Prebuilt binaries|Package managers|Build from source
@@ -40,3 +78,7 @@ Latest version available?|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mar
4078

4179
[^1]: Easy if a previous version is still installed.
4280
[^2]: Possible but requires advanced configuration.
81+
82+
[installation instructions]: https://docs.docker.com/desktop/install/mac-install/
83+
[MacPorts]: https://www.macports.org/
84+
[tagged image versions]: https://github.com/gohugoio/hugo/pkgs/container/hugo/versions?filters%5Bversion_type%5D=tagged

content/en/installation/windows.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,49 @@ winget uninstall --name "Hugo (Extended)"
5252
> [!note]
5353
> See these [detailed instructions](https://discourse.gohugo.io/t/41370) to install GCC on Windows.
5454
55+
## Docker container
56+
57+
> [!note]
58+
> Run the commands in this section from [PowerShell] or a Linux terminal such as WSL or Git Bash. Do not use the Command Prompt.
59+
60+
### Prerequisites {#docker-prerequisites}
61+
62+
Before running the Docker container locally you must install Docker Desktop. See the [installation instructions].
63+
64+
When building your production site in a [CI/CD](g) workflow, whether you can run the Docker container depends on the service provider. For example, GitHub Pages and GitLab Pages allow you to run the Docker container.
65+
66+
To prevent ownership and permission problems, create the Hugo [cache directory](#cache-directory) and ignore the error if the directory already exists:
67+
68+
```text
69+
mkdir -f $Env:LocalAppData/hugo_cache
70+
```
71+
72+
### Commands
73+
74+
To build your site using the latest version:
75+
76+
```sh {copy=true}
77+
docker run --rm -v .:/project -v $Env:LocalAppData/hugo_cache:/cache ghcr.io/gohugoio/hugo:latest build
78+
```
79+
80+
To build your site and start the embedded web server using the latest version:
81+
82+
```sh {copy=true}
83+
docker run --rm -v .:/project -v $Env:LocalAppData/hugo_cache:/cache -p 1313:1313 ghcr.io/gohugoio/hugo:latest server --bind="0.0.0.0"
84+
```
85+
86+
To use a specific version, in the commands above replace `latest` with any of the [tagged image versions]. For example, to build your site using v0.136.1:
87+
88+
```sh {copy=true}
89+
docker run --rm -v .:/project -v $Env:LocalAppData/hugo_cache:/cache ghcr.io/gohugoio/hugo:v0.136.1 build
90+
```
91+
92+
### Cache directory
93+
94+
Attaching the host's Hugo cache directory to the container can significantly enhance performance, particularly for large and image-heavy sites. This allows Hugo to reuse previously generated content, reducing the need for repeated processing and transpilation.
95+
96+
If you are using a custom Hugo cache directory, in the commands above replace `%LocalAppData%/hugo_cache` with the absolute path to your cache directory.
97+
5598
## Comparison
5699

57100
 |Prebuilt binaries|Package managers|Build from source
@@ -66,5 +109,8 @@ Latest version available?|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mar
66109
[^2]: Easy if a previous version is still installed.
67110

68111
[Chocolatey]: https://chocolatey.org/
112+
[installation instructions]: https://docs.docker.com/desktop/install/windows-install/
113+
[PowerShell]: https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows
69114
[Scoop]: https://scoop.sh/
115+
[tagged image versions]: https://github.com/gohugoio/hugo/pkgs/container/hugo/versions?filters%5Bversion_type%5D=tagged
70116
[Winget]: https://learn.microsoft.com/en-us/windows/package-manager/

0 commit comments

Comments
 (0)