Merge commit 'af91eb1997ace34ef5eed0be31646e8483b78096'

This commit is contained in:
Bjørn Erik Pedersen
2026-07-03 10:43:53 +02:00
74 changed files with 776 additions and 510 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
---
title: {{ replace .File.ContentBaseName "-" " " }}
params:
reference:
reference:
---
<!--
@@ -8,7 +8,7 @@ _comment: Do not remove front matter.
```go-html-template
{{ $js := resources.Get "js/main.js" | js.Build (dict "params" (dict "api" "https://example.org/api")) }}
```
And then in your JS file:
```js
@@ -34,7 +34,7 @@ Time zone offsets|`"Z0700" "Z07:00" "Z07" "Z070000" "Z07:00:00"`
{{ $t = time.AsTime $t }}
{{ $t = $t.Format "Jan 02, 2006 3:04 PM Z07:00" }}
{{ $t }} → Jan 27, 2023 11:44 PM -08:00
{{ $t }} → Jan 27, 2023 11:44 PM -08:00
```
Strings such as `PST` and `CET` are not time zones. They are time zone _abbreviations_.
+1 -1
View File
@@ -8,7 +8,7 @@ weight: 40
## Apache License
_Version 2.0, January 2004_
_Version 2.0, January 2004_
_<http://www.apache.org/licenses/>_
### Terms and Conditions for use, reproduction, and distribution
+1 -1
View File
@@ -1,6 +1,6 @@
---
title: Security model
linkTitle: Security
linkTitle: Security
description: A summary of Hugo's security model.
categories: []
keywords: []
@@ -112,7 +112,7 @@ The most common front matter fields are `date`, `draft`, `title`, and `weight`,
: (`map`) A map to define [sites matrix](g) and [sites complements](g) for the page.
<!-- markdownlint-disable MD049 -->
{{< code-toggle file=content/_index.md fm=true >}}
title = 'Home'
[sites.matrix]
+1 -1
View File
@@ -18,5 +18,5 @@ Try to use the same language (e.g., tagline) everywhere:
- Home: https://gohugo.io/
- Docs: https://gohugo.io/documentation/
- Project repo: https://github.com/gohugoio/hugo?tab=readme-ov-file#readme
- Docs repo: https://github.com/gohugoio/hugoDocs?tab=readme-ov-file#readme
- Docs repo: https://github.com/gohugoio/hugoDocs?tab=readme-ov-file#readme
-->
@@ -7,7 +7,7 @@ params:
functions_and_methods:
aliases: [append]
returnType: '[]any'
signatures:
signatures:
- collections.Append ELEMENT [ELEMENT...] SLICE
- collections.Append SLICE1 SLICE2
aliases: [/functions/append]
+1 -1
View File
@@ -47,7 +47,7 @@ The example above generates the _same_ random numbers each time it is called. To
When `N` is greater than `HIGH`, this function returns the full, sorted range [0, `HIGH`) of size `HIGH`:
```go-html-template
{{ collections.D 6 42 7 }} → [0 1 2 3 4 5 6]
{{ collections.D 6 42 7 }} → [0 1 2 3 4 5 6]
```
A common use case is the selection of random pages from a page collection. For example, to render a list of 5 random pages using the [day of the year][] as the seed value:
@@ -12,7 +12,7 @@ aliases: [/functions/shuffle]
---
```go-html-template
{{ collections.Shuffle (slice "a" "b" "c") }} → [b a c]
{{ collections.Shuffle (slice "a" "b" "c") }} → [b a c]
```
The result will vary from one build to the next.
@@ -8,7 +8,7 @@ params:
aliases: [union]
returnType: '[]any'
signatures: [collections.Union SLICE1 SLICE2]
aliases: [/functions/union]
aliases: [/functions/union]
---
@@ -1,5 +1,5 @@
---
title: collections.Where
title: collections.Where
description: Returns a slice by filtering the given slice based on a key, operator, and value.
categories: []
keywords: []
@@ -320,7 +320,7 @@ This template:
Is rendered to:
```html
<ul>
<ul>
<li><a href="/posts/post-2/">Post 2</a></li>
</ul>
```
+5 -5
View File
@@ -175,12 +175,12 @@ The `css.Build` function accepts an options map to fine-tune bundling, minificat
`vars`
: {{< new-in 0.160.0 />}}
: (`map`) A map of key-value pairs used to generate CSS variables. The `css.Build` function injects these variables into the stylesheet when it encounters the `hugo:vars` internal identifier within an `@import` statement.
```go-html-template
{{ $vars := dict
"font-family" "\"Times New Roman\", Times, serif"
"font-size" "24px"
"primary-color" "blue"
"font-size" "24px"
"primary-color" "blue"
}}
{{ $opts := dict "vars" $vars }}
{{ $r := resources.Get "css/main.css" | css.Build $opts }}
@@ -226,9 +226,9 @@ The `css.Build` function accepts an options map to fine-tune bundling, minificat
"font-family" "\"Times New Roman\", Times, serif"
"font-size" "24px"
"primary-color" "blue"
"mobile" (dict
"mobile" (dict
"font-size" "12px"
"primary-color" "red"
"primary-color" "red"
)
}}
{{ $opts := dict "vars" $vars }}
+7 -7
View File
@@ -33,7 +33,7 @@ The `css.Sass` function accepts an options map.
```go-html-template
{{ $opts := dict
"transpiler" "dartsass"
"enableSourceMap" true
"enableSourceMap" true
}}
{{ $r := resources.Get "sass/main.scss" | css.Sass $opts }}
```
@@ -66,7 +66,7 @@ The `css.Sass` function accepts an options map.
```go-html-template
{{ $opts := dict
"transpiler" "dartsass"
"precision" 10
"precision" 10
}}
{{ $r := resources.Get "sass/main.scss" | css.Sass $opts }}
```
@@ -131,10 +131,10 @@ The `css.Sass` function accepts an options map.
```go-html-template
{{ $vars := dict
"font-family" "\"Times New Roman\", Times, serif"
"font-size" "24px"
"font-size" "24px"
"primary-color" "blue"
}}
{{ $opts := dict
{{ $opts := dict
"transpiler" "dartsass"
"vars" $vars
}}
@@ -172,12 +172,12 @@ The `css.Sass` function accepts an options map.
"font-family" "\"Times New Roman\", Times, serif"
"font-size" "24px"
"primary-color" "blue"
"mobile" (dict
"mobile" (dict
"font-size" "12px"
"primary-color" "red"
)
}}
{{ $opts := dict
{{ $opts := dict
"transpiler" "dartsass"
"vars" $vars
}}
@@ -235,7 +235,7 @@ The `css.Sass` function accepts an options map.
{{< /code-toggle >}}
```go-html-template
{{ $opts := dict
{{ $opts := dict
"transpiler" "dartsass"
"vars" site.Params.theme.style }}
{{ $r := resources.Get "sass/main.scss" | css.Sass $opts }}
+1 -1
View File
@@ -7,7 +7,7 @@ params:
functions_and_methods:
aliases: []
returnType: debug.Timer
signatures: [debug.Timer NAME]
signatures: [debug.Timer NAME]
---
Use the `debug.Timer` function to determine execution time for a block of code, useful for finding performance bottlenecks in templates.
+1 -1
View File
@@ -1,6 +1,6 @@
---
title: Fmt functions
linkTitle: fmt
linkTitle: fmt
description: Use these functions to print strings within a template or to print messages to the terminal.
categories: []
keywords: []
+1 -1
View File
@@ -6,7 +6,7 @@ keywords: []
params:
functions_and_methods:
aliases: []
returnType:
returnType:
signatures: [page]
aliases: [/functions/page]
---
+1 -1
View File
@@ -6,7 +6,7 @@ keywords: []
params:
functions_and_methods:
aliases: []
returnType:
returnType:
signatures: [site]
aliases: [/functions/site]
---
@@ -37,7 +37,7 @@ Use with the [`range`][] statement:
```go-html-template
{{ $var := slice 1 2 3 }}
{{ range $var }}
{{ . }} → 1 2 3
{{ . }} → 1 2 3
{{ else }}
{{ print "var is falsy" }}
{{ end }}
+1 -1
View File
@@ -33,7 +33,7 @@ Use with the [`range`][] statement:
```go-html-template
{{ $var := slice 1 2 3 }}
{{ range $var }}
{{ . }} → 1 2 3
{{ . }} → 1 2 3
{{ end }}
```
@@ -6,7 +6,7 @@ keywords: []
params:
functions_and_methods:
aliases: []
returnType:
returnType:
signatures: [range COLLECTION]
aliases: [/functions/range]
---
@@ -47,7 +47,7 @@ With this contrived example:
```go-html-template
{{ $s := slice "foo" "bar" "baz" }}
{{ range $s }}
{{ .Title }}
{{ .Title }}
{{ end }}
```
@@ -67,7 +67,7 @@ This template will render the page title three times:
```go-html-template
{{ $s := slice "foo" "bar" "baz" }}
{{ range $s }}
{{ $.Title }}
{{ $.Title }}
{{ end }}
```
@@ -6,7 +6,7 @@ keywords: []
params:
functions_and_methods:
aliases: []
returnType:
returnType:
signatures: ['template NAME [CONTEXT]']
---
+1 -1
View File
@@ -11,5 +11,5 @@ params:
---
```go-html-template
{{ hugo.Generator }} → <meta name="generator" content="Hugo 0.163.2">
{{ hugo.Generator }} → <meta name="generator" content="Hugo 0.163.3">
```
@@ -5,7 +5,7 @@ categories: []
keywords: []
params:
functions_and_methods:
aliases: []
aliases: []
returnType: bool
signatures: [hugo.IsMultilingual]
---
+1 -1
View File
@@ -11,5 +11,5 @@ params:
---
```go-html-template
{{ hugo.Version }} → 0.163.2
{{ hugo.Version }} → 0.163.3
```
+3 -3
View File
@@ -56,8 +56,8 @@ Specify `level`, `scale`, and `targetDir` as needed to achieve the desired resul
```go-html-template
{{ $text := "https://gohugo.io" }}
{{ $opts := dict
"level" "high"
{{ $opts := dict
"level" "high"
"scale" 3
"targetDir" "images/qr"
}}
@@ -94,7 +94,7 @@ Then hide the QR code with CSS unless printing the page:
/* Show QR code when printing */
@media print {
.qr-code {
display: block;
display: block;
}
}
```
@@ -45,9 +45,9 @@ The "footer" partial renders the site footer. In this contrived example, the foo
You can pass anything in context: a page, a page collection, a scalar value, a slice, or a map. In this example we pass the current page and three scalar values:
```go-html-template
{{ $ctx := dict
{{ $ctx := dict
"page" .
"name" "John Doe"
"name" "John Doe"
"major" "Finance"
"gpa" 4.0
}}
@@ -19,7 +19,7 @@ Let's say you need to publish a file named "site.json" in the root of your `publ
```json
{
"build_date": "2026-04-04T10:46:21-07:00",
"hugo_version": "0.163.2",
"hugo_version": "0.163.3",
"last_modified": "2026-04-04T10:46:26-07:00"
}
```
@@ -84,7 +84,7 @@ To post data:
{{ $url := "https://example.org/api" }}
{{ $opts := dict
"method" "post"
"body" `{"complete": true}`
"body" `{"complete": true}`
"headers" (dict "Content-Type" "application/json")
}}
{{ $resource := resources.GetRemote $url $opts }}
@@ -94,7 +94,7 @@ To override the default cache key:
```go-html-template
{{ $url := "https://example.org/images/a.jpg" }}
{{ $opts := dict
{{ $opts := dict
"key" (print $url (now.Format "2006-01-02"))
}}
{{ $resource := resources.GetRemote $url $opts }}
@@ -109,9 +109,9 @@ Default is `production` for `hugo build` and `development` for `hugo server`.
`HUGO_FILE_X`
: Hugo automatically mounts the following files from your project's root directory under `assets/_jsconfig`:
- `babel.config.js`
- `postcss.config.js`
- `tailwind.config.js`
- `babel.config.js`, `babel.config.mjs`, `babel.config.cjs`
- `postcss.config.js`, `postcss.config.mjs`, `postcss.config.cjs`
- `tailwind.config.js`, `tailwind.config.mjs`, `tailwind.config.cjs`
For each file, Hugo creates a corresponding environment variable named `HUGO_FILE_:filename:`, where `:filename:` is the uppercase version of the filename with periods replaced by underscores. This allows you to access these files within your JavaScript, for example:
@@ -1,5 +1,5 @@
---
title: transform.Emojify
title: transform.Emojify
description: Runs a string through the Emoji emoticons processor.
categories: []
keywords: []
@@ -6,7 +6,7 @@ keywords: [highlight]
params:
functions_and_methods:
aliases: []
returnType: highlight.HighlightResult
returnType: highlight.HighlightResult
signatures: ['transform.HighlightCodeBlock CONTEXT [OPTIONS]']
---
@@ -119,7 +119,7 @@ Step 2
{{- end }}
{{- end -}}
```
Step 3
: In your base template, conditionally include the KaTeX CSS within the head element.
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: urls.AbsURL
title: urls.AbsURL
description: Returns an absolute URL.
categories: []
keywords: []
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: urls.PathEscape
title: urls.PathEscape
description: Returns the given string, applying percent-encoding to special characters and reserved delimiters so it can be safely used as a segment within a URL path.
categories: []
keywords: []
@@ -1,5 +1,5 @@
---
title: urls.PathUnescape
title: urls.PathUnescape
description: Returns the given string, replacing all percent-encoded sequences with the corresponding unescaped characters.
categories: []
keywords: []
@@ -58,7 +58,7 @@ my-project/
├── archetypes/
│ └── default.md
├── assets/
├── config/
├── config/
│ └── _default/
│ └── hugo.toml
├── content/
@@ -115,7 +115,7 @@ Hugo creates a [unified file system](g), allowing you to mount two or more direc
```tree
home/
└── user/
├── my-project/
├── my-project/
│ ├── content/
│ │ ├── books/
│ │ │ ├── _index.md
@@ -125,7 +125,7 @@ home/
│ ├── themes/
│ │ └── my-theme/
│ └── hugo.toml
└── shared-content/
└── shared-content/
└── films/
├── _index.md
├── film-1.md
+1 -1
View File
@@ -82,7 +82,7 @@ hugo server
The [`hugo server`][] command builds your site and serves your pages using a minimal HTTP server. When you run `hugo server` it will display the URL of your local site:
```text
Web Server is available at http://localhost:1313/
Web Server is available at http://localhost:1313/
```
While the server is running, it watches your project directory for changes to assets, configuration, content, data, layouts, translations, and static files. When it detects a change, the server rebuilds your site and refreshes your browser using [LiveReload][].
@@ -8,11 +8,11 @@ aliases: [/hosting-and-deployment/deployment-with-rclone/]
## Assumptions
- A web host running a web server. This could be a shared hosting environment or a VPS.
- Access to your web host with any of the [protocols supported by rclone][], such as SFTP.
- A web host running a web server. This could be a shared hosting environment or a VPS
- Access to your web host with any of the [protocols supported by rclone][], such as SFTP
- A functional static website built with Hugo
- Deploying from an [Rclone][] compatible operating system
- You have [installed Rclone][].
- You have [installed Rclone][]
**NB**: You can remove `--interactive` in the commands below once you are comfortable with rclone, if you wish. Also, `--gc` and `--minify` are optional in the commands below.
@@ -8,7 +8,7 @@ aliases: [/hosting-and-deployment/deployment-with-rsync/]
## Assumptions
- A web host running a web server. This could be a shared hosting environment or a VPS.
- A web host running a web server. This could be a shared hosting environment or a VPS
- Access to your web host with SSH
- A functional static website built with Hugo
@@ -87,7 +87,7 @@ USER=my-user
HOST=my-server.com
DIR=my/directory/to/topologix.fr/ # the directory where your website files should go
hugo build && rsync -avz --delete public/ ${USER}@${HOST}:~/${DIR} # this will delete everything on the server that's not in the local public directory
hugo build && rsync -avz --delete public/ ${USER}@${HOST}:~/${DIR} # this will delete everything on the server that's not in the local public directory
exit 0
```

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 80 KiB

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 60 KiB

@@ -1,12 +1,12 @@
---
title: Host on AWS Amplify
description: Host your site on AWS Amplify.
description: Host your project on AWS Amplify.
categories: []
keywords: []
aliases: [/hosting-and-deployment/hosting-on-aws-amplify/]
---
Use these instructions to enable continuous deployment from a GitHub repository. The same general steps apply if you are using GitLab for version control.
Use these instructions to enable continuous deployment from a GitHub repository. The same general steps apply for other Git providers such as GitLab or Bitbucket.
{{% include "/_common/gitignore-public.md" %}}
@@ -14,89 +14,114 @@ Use these instructions to enable continuous deployment from a GitHub repository.
Please complete the following tasks before continuing:
1. [Create](https://aws.amazon.com/resources/create-account/) an AWS account
1. [Log in](https://console.aws.amazon.com/) to your AWS account
1. [Create](https://github.com/signup) a GitHub account
1. [Log in](https://github.com/login) to your GitHub account
1. [Create](https://github.com/new) a GitHub repository for your project
1. [Create](https://git-scm.com/docs/git-init) a local Git repository for your project with a [remote][] reference to your GitHub repository
1. Create a Hugo project within your local Git repository and test it with the `hugo server` command
1. Commit the changes to your local Git repository and push to your GitHub repository
1. [Create](https://aws.amazon.com/resources/create-account/) an AWS account.
1. [Log in](https://console.aws.amazon.com/) to your AWS account.
1. [Create](https://github.com/signup) a GitHub account.
1. [Log in](https://github.com/login) to your GitHub account.
1. [Create](https://github.com/new) a GitHub repository for your project.
1. [Create](https://git-scm.com/docs/git-init) a local Git repository for your project with a [remote][] reference to your GitHub repository.
1. Create a Hugo project within your local Git repository and test it with the `hugo server` command.
1. Commit the changes to your local Git repository and push to your GitHub repository.
## Procedure
This procedure will enable continuous deployment from a GitHub repository. The procedure is essentially the same if you are using GitLab or Bitbucket.
Step 1
: Create a file named `amplify.yml` in the root of your project.
```sh
touch amplify.yml
```
Step 2
: Copy and paste the YAML below into the file you created. Change the application versions and time zone as needed.
: Create an `amplify.yml` file in the root of your project, adjusting the tool versions and time zone as needed.
```yaml {file="amplify.yml" copy=true}
version: 1
env:
variables:
# Application versions
# Define tool versions
DART_SASS_VERSION: 1.101.0
GO_VERSION: 1.26.4
HUGO_VERSION: 0.163.2
# Time zone
HUGO_VERSION: 0.163.3
NODE_VERSION: 24.16.0
# Set the build time zone
TZ: Europe/Oslo
# Cache
HUGO_CACHEDIR: ${PWD}/.hugo
NPM_CONFIG_CACHE: ${PWD}/.npm
# Set the build cache directory
HUGO_CACHEDIR: ${PWD}/.cache/hugo
frontend:
phases:
preBuild:
commands:
# Create directory for user-specific executable files
- echo "Creating directory for user-specific executable files..."
# Create a temporary directory for downloads
- build_temp_dir=$(mktemp -d)
# Create a local tools directory
- mkdir -p "${HOME}/.local"
# Install Dart Sass
- echo "Installing Dart Sass ${DART_SASS_VERSION}..."
- curl -sLJO "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
- tar -C "${HOME}/.local" -xf "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
- rm "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
- export PATH="${HOME}/.local/dart-sass:${PATH}"
- |
echo "Installing Dart Sass ${DART_SASS_VERSION}..."
curl -sfL --output-dir "${build_temp_dir}" -O "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
tar -C "${HOME}/.local" -xf "${build_temp_dir}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
export PATH="${HOME}/.local/dart-sass:${PATH}"
# Install Go
- echo "Installing Go ${GO_VERSION}..."
- curl -sLJO "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz"
- tar -C "${HOME}/.local" -xf "go${GO_VERSION}.linux-amd64.tar.gz"
- rm "go${GO_VERSION}.linux-amd64.tar.gz"
- export PATH="${HOME}/.local/go/bin:${PATH}"
- |
if [[ -f "go.mod" ]]; then
echo "Installing Go ${GO_VERSION}..."
curl -sfL --output-dir "${build_temp_dir}" -O "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz"
tar -C "${HOME}/.local" -xf "${build_temp_dir}/go${GO_VERSION}.linux-amd64.tar.gz"
export PATH="${HOME}/.local/go/bin:${PATH}"
fi
# Install Hugo
- echo "Installing Hugo ${HUGO_VERSION}..."
- curl -sLJO "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
- mkdir "${HOME}/.local/hugo"
- tar -C "${HOME}/.local/hugo" -xf "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
- rm "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
- export PATH="${HOME}/.local/hugo:${PATH}"
- |
echo "Installing Hugo ${HUGO_VERSION}..."
curl -sfL --output-dir "${build_temp_dir}" -O "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-amd64.tar.gz"
mkdir -p "${HOME}/.local/hugo"
tar -C "${HOME}/.local/hugo" -xf "${build_temp_dir}/hugo_${HUGO_VERSION}_linux-amd64.tar.gz"
export PATH="${HOME}/.local/hugo:${PATH}"
# Verify installations
- echo "Verifying installations..."
- "echo Dart Sass: $(sass --version)"
- "echo Go: $(go version)"
- "echo Hugo: $(hugo version)"
- "echo Node.js: $(node --version)"
# Install Node.js
- |
if [[ -f "package-lock.json" ]]; then
echo "Installing Node.js ${NODE_VERSION}..."
curl -sfL --output-dir "${build_temp_dir}" -O "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz"
tar -C "${HOME}/.local" -xf "${build_temp_dir}/node-v${NODE_VERSION}-linux-x64.tar.gz"
export PATH="${HOME}/.local/node-v${NODE_VERSION}-linux-x64/bin:${PATH}"
fi
# Install Node.js dependencies
- echo "Installing Node.js dependencies..."
- "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci --prefer-offline || true"
# Log tool versions
- |
echo "Logging tool versions..."
command -v sass &> /dev/null && echo "Dart Sass: $(sass --version)" || echo "Dart Sass: not installed"
command -v go &> /dev/null && echo "Go: $(go version)" || echo "Go: not installed"
command -v hugo &> /dev/null && echo "Hugo: $(hugo version)" || echo "Hugo: not installed"
command -v node &> /dev/null && echo "Node.js: $(node --version)" || echo "Node.js: not installed"
# Configure Git
- echo "Configuring Git..."
- git config --global core.quotepath false
- |
echo "Configuring Git..."
git config --global core.quotepath false
# Fetch full Git history
- |
if [[ $(git rev-parse --is-shallow-repository) == true ]]; then
echo "Fetching full Git history..."
git fetch --unshallow
fi
# Initialize Git submodules
- |
if [[ -f .gitmodules ]]; then
echo "Initializing Git submodules..."
git submodule update --init --recursive
fi
# Install Node.js dependencies
- |
if [[ -f package-lock.json ]]; then
echo "Installing Node.js dependencies..."
npm ci
fi
build:
commands:
- echo "Building site..."
- echo "Building the project..."
- hugo build --gc --minify
artifacts:
baseDirectory: public
@@ -104,10 +129,19 @@ Step 2
- '**/*'
cache:
paths:
- ${HUGO_CACHEDIR}/**/*
- ${NPM_CONFIG_CACHE}/**/*
- .cache/hugo/**/*
```
Step 2
: In your project configuration, change the location of the image cache to the [`cacheDir`][] as shown below:
{{< code-toggle file=hugo copy=true >}}
[caches.images]
dir = ':cacheDir/images'
{{< /code-toggle >}}
See [configure file caches][] for more information.
Step 3
: Commit and push the change to your GitHub repository.
@@ -123,27 +157,27 @@ Step 4
Step 5
: Choose a source code provider, then press the **Next** button.
![screen capture](amplify-step-05.png)
![screen capture](amplify-01.png)
Step 6
: Authorize AWS Amplify to access your GitHub account.
![screen capture](amplify-step-06.png)
![screen capture](amplify-02.png)
Step 7
: Select your personal account or relevant organization.
![screen capture](amplify-step-07.png)
![screen capture](amplify-03.png)
Step 8
: Authorize access to one or more repositories.
![screen capture](amplify-step-08.png)
![screen capture](amplify-04.png)
Step 9
: Select a repository and branch, then press the **Next** button.
![screen capture](amplify-step-09.png)
![screen capture](amplify-05.png)
Step 10
: On the "App settings" page, scroll to the bottom then press the **Next** button. Amplify reads the `amplify.yml` file you created in Steps 1-3 instead of using the values on this page.
@@ -154,7 +188,9 @@ Step 11
Step 12
: When your site has finished deploying, press the **Visit deployed URL** button to view your published site.
![screen capture](amplify-step-11.png)
![screen capture](amplify-06.png)
[Amplify Console]: https://console.aws.amazon.com/amplify/apps
[`cacheDir`]: /configuration/all/#cachedir
[configure file caches]: /configuration/caches/
[remote]: https://git-scm.com/docs/git-remote
@@ -1,6 +1,6 @@
---
title: Host on Azure Static Web Apps
description: Host your site on Azure Static Web Apps.
description: Host your project on Azure Static Web Apps.
categories: []
keywords: []
aliases: [/hosting-and-deployment/hosting-on-azure-static-web-apps/]
@@ -1,11 +1,11 @@
---
title: Host on Cloudflare
description: Host your site on Cloudflare.
description: Host your project on Cloudflare.
categories: []
keywords: []
---
Use these instructions to enable continuous deployment from a GitHub repository. The same general steps apply if you are using GitLab for version control.
Use these instructions to enable continuous deployment from a GitHub repository. The same general steps apply for other Git providers such as GitLab or Bitbucket.
{{% include "/_common/gitignore-public.md" %}}
@@ -25,39 +25,53 @@ Please complete the following tasks before continuing:
## Procedure
Step 1
: Create a `wrangler.toml` file in the root of your project.
: Create a `wrangler.jsonc` file in the root of your project.
```toml {file="wrangler.toml" copy=true}
name = 'hosting-cloudflare-worker'
compatibility_date = '2025-07-31'
[build]
command = 'chmod a+x build.sh && ./build.sh'
[assets]
directory = './public'
not_found_handling = '404-page'
```jsonc {file="wrangler.jsonc" copy=true}
{
// Set this to the name of your project.
"name": "test",
// Set this to today's date in YYYY-MM-DD format.
"compatibility_date": "2026-06-19",
"build": {
"command": "chmod a+x build.sh && ./build.sh"
},
"assets": {
"directory": "./public",
"not_found_handling": "404-page"
}
}
```
Step 2
: Create a `build.sh` file in the root of your project.
: Create a `build.sh` file in the root of your project, adjusting the tool versions and time zone as needed.
```sh {file="build.sh" copy=true}
#!/usr/bin/env bash
#------------------------------------------------------------------------------
# @file
# Builds a Hugo site hosted on a Cloudflare Worker.
# Builds a Hugo project hosted on a Cloudflare Worker.
#------------------------------------------------------------------------------
# Exit on error, undefined variables, or pipe failures
set -euo pipefail
build_temp_dir=""
# Define tool versions
DART_SASS_VERSION=1.101.0
GO_VERSION=1.26.4
HUGO_VERSION=0.163.3
NODE_VERSION=24.16.0
# Set the build time zone
TZ=Europe/Oslo
# Set the build cache directory
HUGO_CACHEDIR="${PWD}/.cache/hugo"
# Perform cleanup
cleanup() {
if [[ -n "${build_temp_dir}" && -d "${build_temp_dir}" ]]; then
if [[ -n "${build_temp_dir:-}" && -d "${build_temp_dir}" ]]; then
rm -rf "${build_temp_dir}"
fi
}
@@ -66,75 +80,78 @@ Step 2
trap cleanup EXIT SIGINT SIGTERM
main() {
# Define tool versions
DART_SASS_VERSION=1.101.0
GO_VERSION=1.26.4
HUGO_VERSION=0.163.2
NODE_VERSION=24.16.0
# Export the build time zone
export TZ
# Set the build timezone
export TZ=Europe/Oslo
# Export the build cache directory
export HUGO_CACHEDIR
# Set the build cache directory
export HUGO_CACHEDIR="${PWD}/.cache/hugo_cache"
# Create and move into a temporary directory for downloads
# Create a temporary directory for downloads
build_temp_dir=$(mktemp -d)
pushd "${build_temp_dir}" > /dev/null
# Create the local tools directory
# Create a local tools directory
mkdir -p "${HOME}/.local"
# Install Dart Sass
echo "Installing Dart Sass ${DART_SASS_VERSION}..."
curl -sLO "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
tar -C "${HOME}/.local" -xf "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
curl -sfL --output-dir "${build_temp_dir}" -O "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
tar -C "${HOME}/.local" -xf "${build_temp_dir}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
export PATH="${HOME}/.local/dart-sass:${PATH}"
# Install Go
echo "Installing Go ${GO_VERSION}..."
curl -sLO "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz"
tar -C "${HOME}/.local" -xf "go${GO_VERSION}.linux-amd64.tar.gz"
export PATH="${HOME}/.local/go/bin:${PATH}"
if [[ -f "go.mod" ]]; then
echo "Installing Go ${GO_VERSION}..."
curl -sfL --output-dir "${build_temp_dir}" -O "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz"
tar -C "${HOME}/.local" -xf "${build_temp_dir}/go${GO_VERSION}.linux-amd64.tar.gz"
export PATH="${HOME}/.local/go/bin:${PATH}"
fi
# Install Hugo
echo "Installing Hugo ${HUGO_VERSION}..."
curl -sLO "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-amd64.tar.gz"
curl -sfL --output-dir "${build_temp_dir}" -O "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-amd64.tar.gz"
mkdir -p "${HOME}/.local/hugo"
tar -C "${HOME}/.local/hugo" -xf "hugo_${HUGO_VERSION}_linux-amd64.tar.gz"
tar -C "${HOME}/.local/hugo" -xf "${build_temp_dir}/hugo_${HUGO_VERSION}_linux-amd64.tar.gz"
export PATH="${HOME}/.local/hugo:${PATH}"
# Install Node.js
echo "Installing Node.js ${NODE_VERSION}..."
curl -sLO "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz"
tar -C "${HOME}/.local" -xf "node-v${NODE_VERSION}-linux-x64.tar.xz"
export PATH="${HOME}/.local/node-v${NODE_VERSION}-linux-x64/bin:${PATH}"
if [[ -f "package-lock.json" ]]; then
echo "Installing Node.js ${NODE_VERSION}..."
curl -sfL --output-dir "${build_temp_dir}" -O "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz"
tar -C "${HOME}/.local" -xf "${build_temp_dir}/node-v${NODE_VERSION}-linux-x64.tar.gz"
export PATH="${HOME}/.local/node-v${NODE_VERSION}-linux-x64/bin:${PATH}"
fi
# Return to the project root
popd > /dev/null
# Verify installations
echo "Verifying installations..."
echo Dart Sass: "$(sass --version)"
echo Go: "$(go version)"
echo Hugo: "$(hugo version)"
echo Node.js: "$(node --version)"
# Log tool versions
echo "Logging tool versions..."
command -v sass &> /dev/null && echo "Dart Sass: $(sass --version)" || echo "Dart Sass: not installed"
command -v go &> /dev/null && echo "Go: $(go version)" || echo "Go: not installed"
command -v hugo &> /dev/null && echo "Hugo: $(hugo version)" || echo "Hugo: not installed"
command -v node &> /dev/null && echo "Node.js: $(node --version)" || echo "Node.js: not installed"
# Configure Git
echo "Configuring Git..."
git config --global core.quotepath false
if [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then
# Fetch full Git history
if [[ $(git rev-parse --is-shallow-repository) == true ]]; then
echo "Fetching full Git history..."
git fetch --unshallow
fi
# Initialize Git submodules
if [[ -f .gitmodules ]]; then
echo "Initializing Git submodules..."
git submodule update --init --recursive
fi
# Install Node.js dependencies
if [ -f package-lock.json ]; then
if [[ -f package-lock.json ]]; then
echo "Installing Node.js dependencies..."
npm ci
fi
# Build the site
echo "Building the site..."
# Build the project
echo "Building the project..."
hugo build --gc --minify
}
@@ -142,39 +159,49 @@ Step 2
```
Step 3
: Commit the changes to your local Git repository and push to your GitHub repository.
: In your project configuration, change the location of the image cache to the [`cacheDir`][] as shown below:
{{< code-toggle file=hugo copy=true >}}
[caches.images]
dir = ':cacheDir/images'
{{< /code-toggle >}}
See [configure file caches][] for more information.
Step 4
: Commit the changes to your local Git repository and push to your GitHub repository.
Step 5
: In the upper right corner of the Cloudflare [dashboard][], press the **Add** button and select "Workers" from the drop down menu.
![screen capture](cloudflare-01.png)
Step 5
Step 6
: Verify your account if prompted.
![screen capture](cloudflare-02.png)
Step 6
Step 7
: On the "Create a Worker" page, under the "Ship something new" heading, press the **Connect GitHub** button.
![screen capture](cloudflare-03.png)
Step 7
Step 8
: Select the GitHub account where you want to install the Cloudflare Workers and Pages application.
![screen capture](cloudflare-04.png)
Step 8
Step 9
: Authorize the Cloudflare Workers and Pages application to access all repositories or only select repositories, then press the **Install & Authorize** button.
![screen capture](cloudflare-05.png)
Step 9
Step 10
: On the "Create a Worker" page, under the "Select a repository" heading, select the repository to deploy, then press the **Next** button.
![screen capture](cloudflare-06.png)
Step 10
Step 11
: On the "Create a Worker" page, under the "Set up your application" heading, perform the following steps:
1. Provide a **Project name**.
@@ -184,7 +211,7 @@ Step 10
1. In the **Variable value** field, enter `true`.
1. Press the **Deploy** button.
Step 11
Step 12
: Wait for the site to build and deploy, then press the **Visit** button in the upper left corner of your screen.
![screen capture](cloudflare-07.png)
@@ -193,13 +220,58 @@ In the future, whenever you push a change from your local Git repository, Cloudf
## Build cache
The build script shown in [Step 2](#step-2) sets Hugo's [cache directory][] to the path required by Cloudflare's build cache, which is disabled by default. To enable the Cloudflare build cache:
The build script shown in [Step 2](#step-2) sets Hugo's [`cacheDir`][] to the path required by Cloudflare's build cache, which is disabled by default. To enable the Cloudflare build cache, you must complete two steps.
First, your project must have both a `package.json` and `package-lock.json` file in the project root. If you have only a package.json file, run `npm install` to create the corresponding `package-lock.json` file. If your project does not require any Node.js packages, create both files by running `npm init -y && npm install`.
Second, you must enable the build cache in your project dashboard.
1. Navigate to Workers & Pages Overview on the [dashboard][].
1. Find your Workers project.
1. Go to **Settings** > **Build** > **Build cache**.
1. Go to **Settings**&nbsp;>&nbsp;**Build**&nbsp;>&nbsp;**Build cache**.
1. Press the **Enable** button.
[cache directory]: /configuration/all/#cache-directory
## Scheduled builds
If your site uses [`resources.GetRemote`][] to fetch external data at build time, that data is embedded in the static HTML when the site is built. Without a scheduled build, the data only refreshes when someone commits code to the repository. To keep content current, you can trigger a rebuild on a schedule by creating a Cloudflare deploy hook and calling it from a GitHub Actions workflow.
Step 1
: In the Cloudflare [dashboard][], go to **Workers & Pages**. Select your project, then navigate to **Settings**&nbsp;>&nbsp;**Builds**&nbsp;>&nbsp;**Deploy Hooks**. Press **Create deploy hook**, provide a name (e.g., `github-cron`), and copy the generated URL.
Step 2
: In your GitHub repository, go to **Settings**&nbsp;>&nbsp;**Secrets and variables**&nbsp;>&nbsp;**Actions**. Press **New repository secret**, name it `CLOUDFLARE_DEPLOY_HOOK`, paste the deploy hook URL as the value, and save.
Step 3
: Create a GitHub Actions workflow file in your repository.
```yaml {file=".github/workflows/scheduled-cloudflare-deploy.yaml" copy=true}
name: github-cron
on:
schedule:
- cron: "42 7 * * *"
timezone: Etc/UTC
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Trigger Cloudflare deploy hook
run: curl -X POST "${{ secrets.CLOUDFLARE_DEPLOY_HOOK }}"
```
Adjust the [`cron`][] expression to set your desired build schedule. In the example above, the job is scheduled to run every day at 7:42 AM UTC.
Step 4
: Commit the changes to your local Git repository and push to your GitHub repository.
> [!NOTE]
> The schedule event can be delayed during periods of high loads of GitHub Actions workflow runs. High load times include the start of every hour. If the load is sufficiently high enough, some queued jobs may be dropped. To decrease the chance of delay, schedule your workflow to run at a different time of the hour, or use a dedicated third-party scheduling service such as [Google Cloud Scheduler][] or [cron-job.org][].
[`cacheDir`]: /configuration/all/#cachedir
[`cron`]: https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#schedule
[`resources.GetRemote`]: /functions/resources/getremote/
[configure file caches]: /configuration/caches/
[cron-job.org]: https://cron-job.org/en/
[dashboard]: https://dash.cloudflare.com/
[remote]: https://git-scm.com/docs/git-remote
[Google Cloud Scheduler]: https://docs.cloud.google.com/scheduler/docs/overview
@@ -1,6 +1,6 @@
---
title: Host on Firebase
description: Host your site on Firebase.
description: Host your project on Firebase.
categories: []
keywords: []
aliases: [/hosting-and-deployment/hosting-on-firebase/]
@@ -1,12 +1,12 @@
---
title: Host on GitHub Pages
description: Host your site on GitHub Pages.
description: Host your project on GitHub Pages.
categories: []
keywords: []
aliases: [/hosting-and-deployment/hosting-on-github/]
---
Use these instructions to enable continuous deployment from a GitHub repository using GitHub Actions.
Use these instructions to enable continuous deployment from a GitHub repository to GitHub Pages.
{{% include "/_common/gitignore-public.md" %}}
@@ -21,12 +21,12 @@ There are three types of GitHub Pages sites: project, user, and organization. Pr
Please complete the following tasks before continuing:
1. [Create](https://github.com/signup) a GitHub account
1. [Log in][] to your GitHub account
1. [Create](https://github.com/new) a GitHub repository for your project
1. [Create](https://git-scm.com/docs/git-init) a local Git repository for your project with a [remote][] reference to your GitHub repository
1. Create a Hugo project within your local Git repository and test it with the `hugo server` command
1. Commit the changes to your local Git repository and push to your GitHub repository
1. [Create](https://github.com/signup) a GitHub account.
1. [Log in][] to your GitHub account.
1. [Create](https://github.com/new) a GitHub repository for your project.
1. [Create](https://git-scm.com/docs/git-init) a local Git repository for your project with a [remote][] reference to your GitHub repository.
1. Create a Hugo project within your local Git repository and test it with the `hugo server` command.
1. Commit the changes to your local Git repository and push to your GitHub repository.
## Procedure
@@ -40,25 +40,7 @@ Step 1
![screen capture](gh-pages-02.png)
Step 2
: In your project configuration, change the location of the image cache to the [`cacheDir`][] as shown below:
{{< code-toggle file=hugo copy=true >}}
[caches.images]
dir = ':cacheDir/images'
{{< /code-toggle >}}
See [configure file caches][] for more information.
Step 3
: Create a file named `hugo.yaml` in a directory named `.github/workflows`.
```sh
mkdir -p .github/workflows
touch .github/workflows/hugo.yaml
```
Step 4
: Copy and paste the YAML below into the file you created.
: Create a `hugo.yaml` file in the `.github/workflows` directory, adjusting the tool versions and time zone as needed.
```yaml {file=".github/workflows/hugo.yaml" copy=true}
name: Build and deploy
@@ -81,10 +63,13 @@ Step 4
build:
runs-on: ubuntu-latest
env:
# Define tool versions
DART_SASS_VERSION: 1.101.0
GO_VERSION: 1.26.4
HUGO_VERSION: 0.163.2
HUGO_VERSION: 0.163.3
NODE_VERSION: 24.16.0
# Set the build time zone
TZ: Europe/Oslo
steps:
- name: Checkout
@@ -92,97 +77,140 @@ Step 4
with:
submodules: recursive
fetch-depth: 0
- name: Setup Go
- name: Setup Pages
id: pages
uses: actions/configure-pages@v6
- name: Create a local tools directory
run: |
mkdir -p "${HOME}/.local"
- name: Install Go
if: hashFiles('go.mod') != ''
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache: false
- name: Setup Node.js
- name: Install Node.js
if: hashFiles('package-lock.json') != ''
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup Pages
id: pages
uses: actions/configure-pages@v6
- name: Create directory for user-specific executable files
run: |
mkdir -p "${HOME}/.local"
- name: Install Dart Sass
run: |
curl -sLJO "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
tar -C "${HOME}/.local" -xf "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
rm "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
echo "Installing Dart Sass ${DART_SASS_VERSION}..."
curl -sfL --output-dir "${{ runner.temp }}" -O "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
tar -C "${HOME}/.local" -xf "${{ runner.temp }}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
echo "${HOME}/.local/dart-sass" >> "${GITHUB_PATH}"
- name: Install Hugo
run: |
curl -sLJO "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
echo "Installing Hugo ${HUGO_VERSION}..."
curl -sfL --output-dir "${{ runner.temp }}" -O "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
mkdir "${HOME}/.local/hugo"
tar -C "${HOME}/.local/hugo" -xf "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
rm "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
tar -C "${HOME}/.local/hugo" -xf "${{ runner.temp }}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
echo "${HOME}/.local/hugo" >> "${GITHUB_PATH}"
- name: Verify installations
- name: Log tool versions
run: |
echo "Dart Sass: $(sass --version)"
echo "Go: $(go version)"
echo "Hugo: $(hugo version)"
echo "Node.js: $(node --version)"
- name: Install Node.js dependencies
run: |
[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true
echo "Logging tool versions..."
command -v sass &> /dev/null && echo "Dart Sass: $(sass --version)" || echo "Dart Sass: not installed"
command -v go &> /dev/null && echo "Go: $(go version)" || echo "Go: not installed"
command -v hugo &> /dev/null && echo "Hugo: $(hugo version)" || echo "Hugo: not installed"
command -v node &> /dev/null && echo "Node.js: $(node --version)" || echo "Node.js: not installed"
- name: Configure Git
run: |
echo "Configuring Git..."
git config --global core.quotepath false
- name: Fetch full Git history
run: |
if [[ $(git rev-parse --is-shallow-repository) == true ]]; then
echo "Fetching full Git history..."
git fetch --unshallow
fi
- name: Initialize Git submodules
run: |
if [[ -f .gitmodules ]]; then
echo "Initializing Git submodules..."
git submodule update --init --recursive
fi
- name: Install Node.js dependencies
run: |
if [[ -f package-lock.json ]]; then
echo "Installing Node.js dependencies..."
npm ci
fi
- name: Cache restore
id: cache-restore
uses: actions/cache/restore@v5
with:
path: ${{ runner.temp }}/hugo_cache
key: hugo-${{ github.run_id }}
restore-keys:
hugo-
- name: Build the site
restore-keys: hugo-
- name: Build
run: |
echo "Building the project..."
hugo build \
--gc \
--minify \
--baseURL "${{ steps.pages.outputs.base_url }}/" \
--cacheDir "${{ runner.temp }}/hugo_cache"
- name: Cache save
id: cache-save
uses: actions/cache/save@v5
with:
path: ${{ runner.temp }}/hugo_cache
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
- name: Upload artifact
uses: actions/upload-pages-artifact@v5
with:
include-hidden-files: false
path: ./public
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
```
Step 5
Step 3
: In your project configuration, change the location of the image cache to the [`cacheDir`][] as shown below:
{{< code-toggle file=hugo copy=true >}}
[caches.images]
dir = ':cacheDir/images'
{{< /code-toggle >}}
See [configure file caches][] for more information.
Step 4
: Commit the changes to your local Git repository and push to your GitHub repository.
Step 6
Step 5
: From GitHub's main menu, choose **Actions**. You will see something like this:
![screen capture](gh-pages-03.png)
Step 7
Step 6
: When GitHub has finished building and deploying your site, the color of the status indicator will change to green.
![screen capture](gh-pages-04.png)
Step 8
Step 7
: Click on the commit message as shown above. Under the deploy step, you will see a link to your live site.
![screen capture](gh-pages-05.png)
@@ -1,12 +1,12 @@
---
title: Host on GitLab Pages
description: Host your site on GitLab Pages.
description: Host your project on GitLab Pages.
categories: []
keywords: []
aliases: [/hosting-and-deployment/hosting-on-gitlab/]
---
Use these instructions to enable continuous deployment from a GitLab repository.
Use these instructions to enable continuous deployment from a GitLab repository to GitLab Pages.
{{% include "/_common/gitignore-public.md" %}}
@@ -14,12 +14,12 @@ Use these instructions to enable continuous deployment from a GitLab repository.
Please complete the following tasks before continuing:
1. [Create](https://gitlab.com/users/sign_up) a GitLab account
1. [Log in](https://gitlab.com/users/sign_in) to your GitLab account
1. [Create](https://gitlab.com/projects/new) a GitLab repository for your project
1. [Create](https://git-scm.com/docs/git-init) a local Git repository for your project with a [remote][] reference to your GitLab repository
1. Create a Hugo project within your local Git repository and test it with the `hugo server` command
1. Commit the changes to your local Git repository and push to your GitLab repository
1. [Create](https://gitlab.com/users/sign_up) a GitLab account.
1. [Log in](https://gitlab.com/users/sign_in) to your GitLab account.
1. [Create](https://gitlab.com/projects/new) a GitLab repository for your project.
1. [Create](https://git-scm.com/docs/git-init) a local Git repository for your project with a [remote][] reference to your GitLab repository.
1. Create a Hugo project within your local Git repository and test it with the `hugo server` command.
1. Commit the changes to your local Git repository and push to your GitLab repository.
## BaseURL
@@ -28,86 +28,38 @@ The [`baseURL`][] in your project configuration must reflect the full URL of you
## Procedure
Step 1
: Create a `.gitlab-ci.yml` file in the root of your project.
: Create a `.gitlab-ci.yml` file in the root of your project, adjusting the tool versions and time zone as needed.
```yaml {file=".gitlab-ci.yml" copy=true}
variables:
# Application versions
# Define tool versions
DART_SASS_VERSION: 1.101.0
HUGO_VERSION: 0.163.2
GO_VERSION: 1.26.4
HUGO_VERSION: 0.163.3
NODE_VERSION: 24.16.0
# Git
# Set the build timezone
TZ: Europe/Oslo
# Set the build cache directory
HUGO_CACHEDIR: ${CI_PROJECT_DIR}/.cache/hugo
# Set the repository clone and fetch strategy
GIT_DEPTH: 0
GIT_STRATEGY: clone
GIT_SUBMODULE_STRATEGY: recursive
# Time zone
TZ: Europe/Oslo
cache:
key: ${CI_COMMIT_REF_SLUG}
fallback_keys:
- ${CI_DEFAULT_BRANCH}
paths:
- .cache/hugo
image:
name: golang:1.26.4-bookworm
name: buildpack-deps:bookworm
pages:
stage: deploy
script:
- |
# Create directory for user-specific executable files
echo "Creating directory for user-specific executable files..."
mkdir -p "${HOME}/.local"
# Install utilities
echo "Installing utilities..."
apt-get update
apt-get install -y brotli xz-utils zstd
# Install Dart Sass
echo "Installing Dart Sass ${DART_SASS_VERSION}..."
curl -sLJO "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
tar -C "${HOME}/.local" -xf "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
rm "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
export PATH="${HOME}/.local/dart-sass:${PATH}"
# Install Hugo
echo "Installing Hugo ${HUGO_VERSION}..."
curl -sLJO "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-amd64.tar.gz"
mkdir -p "${HOME}/.local/hugo"
tar -C "${HOME}/.local/hugo" -xf "hugo_${HUGO_VERSION}_linux-amd64.tar.gz"
rm "hugo_${HUGO_VERSION}_linux-amd64.tar.gz"
export PATH="${HOME}/.local/hugo:${PATH}"
# Install Node.js
echo "Installing Node.js ${NODE_VERSION}..."
curl -sLJO "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz"
tar -C "${HOME}/.local" -xf "node-v${NODE_VERSION}-linux-x64.tar.xz"
rm "node-v${NODE_VERSION}-linux-x64.tar.xz"
export PATH="${HOME}/.local/node-v${NODE_VERSION}-linux-x64/bin:${PATH}"
# Verify installations
echo "Verifying installations..."
echo "Dart Sass: $(sass --version)"
echo "Go: $(go version)"
echo "Hugo: $(hugo version)"
echo "Node.js: $(node --version)"
echo "brotli: $(brotli --version)"
echo "xz: $(xz --version)"
echo "zstd: $(zstd --version)"
# Install Node.js dependencies
echo "Installing Node.js dependencies..."
[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci --prefer-offline || true
# Configure Git
echo "Configuring Git..."
git config --global core.quotepath false
# Build site
echo "Building site..."
hugo --gc --minify --baseURL "${CI_PAGES_URL}"
# Compress published files
echo "Compressing published files..."
find public/ -type f -regextype posix-extended -regex '.+\.(css|html|js|json|mjs|svg|txt|xml)$' -print0 > files.txt
time xargs --null --max-procs=0 --max-args=1 brotli --quality=10 --force --keep < files.txt
time xargs --null --max-procs=0 --max-args=1 gzip -9 --force --keep < files.txt
- chmod a+x build.sh && ./build.sh
artifacts:
paths:
- public
@@ -116,20 +68,135 @@ Step 1
```
Step 2
: Commit the changes to your local Git repository and push to your GitLab repository.
: Create a `build.sh` file in the root of your project.
```sh {file="build.sh" copy=true}
#!/usr/bin/env bash
#------------------------------------------------------------------------------
# @file
# Builds a Hugo project hosted on GitLab Pages.
#------------------------------------------------------------------------------
# Exit on error, undefined variables, or pipe failures
set -euo pipefail
# Perform cleanup
cleanup() {
if [[ -n "${build_temp_dir:-}" && -d "${build_temp_dir}" ]]; then
rm -rf "${build_temp_dir}"
fi
}
# Register the cleanup trap
trap cleanup EXIT SIGINT SIGTERM
main() {
# Create a temporary directory for downloads
build_temp_dir=$(mktemp -d)
# Create a local tools directory
mkdir -p "${HOME}/.local"
# Install utilities
echo "Installing utilities..."
apt-get update > /dev/null
apt-get install -y brotli > /dev/null
# Install Dart Sass
echo "Installing Dart Sass ${DART_SASS_VERSION}..."
curl -sfLO --output-dir "${build_temp_dir}" "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
tar -C "${HOME}/.local" -xf "${build_temp_dir}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
export PATH="${HOME}/.local/dart-sass:${PATH}"
# Install Go
if [[ -f "${CI_PROJECT_DIR}/go.mod" ]]; then
echo "Installing Go ${GO_VERSION}..."
curl -sfLO --output-dir "${build_temp_dir}" "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz"
tar -C "${HOME}/.local" -xf "${build_temp_dir}/go${GO_VERSION}.linux-amd64.tar.gz"
export PATH="${HOME}/.local/go/bin:${PATH}"
fi
# Install Hugo
echo "Installing Hugo ${HUGO_VERSION}..."
curl -sfLO --output-dir "${build_temp_dir}" "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-amd64.tar.gz"
mkdir -p "${HOME}/.local/hugo"
tar -C "${HOME}/.local/hugo" -xf "${build_temp_dir}/hugo_${HUGO_VERSION}_linux-amd64.tar.gz"
export PATH="${HOME}/.local/hugo:${PATH}"
# Install Node.js
if [[ -f "${CI_PROJECT_DIR}/package-lock.json" ]]; then
echo "Installing Node.js ${NODE_VERSION}..."
curl -sfLO --output-dir "${build_temp_dir}" "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz"
tar -C "${HOME}/.local" -xf "${build_temp_dir}/node-v${NODE_VERSION}-linux-x64.tar.gz"
export PATH="${HOME}/.local/node-v${NODE_VERSION}-linux-x64/bin:${PATH}"
fi
# Log tool versions
echo "Logging tool versions..."
command -v sass &> /dev/null && echo "Dart Sass: $(sass --version)" || echo "Dart Sass: not installed"
command -v go &> /dev/null && echo "Go: $(go version)" || echo "Go: not installed"
command -v hugo &> /dev/null && echo "Hugo: $(hugo version)" || echo "Hugo: not installed"
command -v node &> /dev/null && echo "Node.js: $(node --version)" || echo "Node.js: not installed"
# Configure Git
echo "Configuring Git..."
git config --global core.quotepath false
# Fetch full Git history
if [[ $(git rev-parse --is-shallow-repository) == true ]]; then
echo "Fetching full Git history..."
git fetch --unshallow
fi
# Initialize Git submodules
if [[ -f .gitmodules ]]; then
echo "Initializing Git submodules..."
git submodule update --init --recursive
fi
# Install Node.js dependencies
if [[ -f package-lock.json ]]; then
echo "Installing Node.js dependencies..."
npm ci
fi
# Build the project
echo "Building the project..."
hugo build --gc --minify
# Compress published files
echo "Compressing published files..."
find public/ -type f -regextype posix-extended -regex '.+\.(cjs|css|html|js|json|mjs|svg|txt|xml)$' -print0 > "${build_temp_dir}/files.txt"
xargs --null --max-procs=0 --max-args=1 brotli --quality=10 --force --keep < "${build_temp_dir}/files.txt"
xargs --null --max-procs=0 --max-args=1 gzip -9 --force --keep < "${build_temp_dir}/files.txt"
}
main "$@"
```
Step 3
: From your GitLab repository, navigate to **Build**&nbsp;>&nbsp;**Pipelines** to follow the CI pipeline building your page.
: In your project configuration, change the location of the image cache to the [`cacheDir`][] as shown below:
{{< code-toggle file=hugo copy=true >}}
[caches.images]
dir = ':cacheDir/images'
{{< /code-toggle >}}
See [configure file caches][] for more information.
Step 4
: Commit the changes to your local Git repository and push to your GitLab repository.
Step 5
: From your GitLab repository, navigate to **Build**&nbsp;>&nbsp;**Pipelines** to follow the CI pipeline building your page.
Step 6
: When the pipeline has passed, your new website is available at `https://<YourUsername>.gitlab.io/<your-hugo-site>/`.
In the future, whenever you push a change from your local Git repository, GitLab Pages will rebuild and deploy your site.
## Other resources
- [GitLab Pages documentation][]
[GitLab Pages documentation]: https://docs.gitlab.com/user/project/pages/
[`baseURL`]: /configuration/all/#baseurl
[`cacheDir`]: /configuration/all/#cachedir
[configure file caches]: /configuration/caches/
[remote]: https://git-scm.com/docs/git-remote
@@ -1,12 +1,12 @@
---
title: Host on Netlify
description: Host your site on Netlify.
description: Host your project on Netlify.
categories: []
keywords: []
aliases: [/hosting-and-deployment/hosting-on-netlify/]
---
Use these instructions to enable continuous deployment from a GitHub repository. The same general steps apply if you are using Azure DevOps, Bitbucket, or GitLab for version control.
Use these instructions to enable continuous deployment from a GitHub repository. The same general steps apply for other Git providers such as GitLab or Bitbucket.
{{% include "/_common/gitignore-public.md" %}}
@@ -14,27 +14,24 @@ Use these instructions to enable continuous deployment from a GitHub repository.
Please complete the following tasks before continuing:
1. [Create](https://app.netlify.com/signup) a Netlify account
1. [Log in](https://app.netlify.com/login) to your Netlify account
1. [Create](https://github.com/signup) a GitHub account
1. [Log in](https://github.com/login) to your GitHub account
1. [Create](https://github.com/new) a GitHub repository for your project
1. [Create](https://git-scm.com/docs/git-init) a local Git repository for your project with a [remote][] reference to your GitHub repository
1. Create a Hugo project within your local Git repository and test it with the `hugo server` command
1. Commit the changes to your local Git repository and push to your GitHub repository
1. [Create](https://app.netlify.com/signup) a Netlify account.
1. [Log in](https://app.netlify.com/login) to your Netlify account.
1. [Create](https://github.com/signup) a GitHub account.
1. [Log in](https://github.com/login) to your GitHub account.
1. [Create](https://github.com/new) a GitHub repository for your project.
1. [Create](https://git-scm.com/docs/git-init) a local Git repository for your project with a [remote][] reference to your GitHub repository.
1. Create a Hugo project within your local Git repository and test it with the `hugo server` command.
1. Commit the changes to your local Git repository and push to your GitHub repository.
## Procedure
<!-- Using "text" as the code block language because "toml" looks terrible. -->
Step 1
: Create a `netlify.toml` file in the root of your project.
: Create a `netlify.toml` file in the root of your project, adjusting the tool versions and time zone as needed.
```toml {file="netlify.toml" copy=true}
[build.environment]
DART_SASS_VERSION = "1.101.0"
GO_VERSION = "1.26.4"
HUGO_VERSION = "0.163.2"
HUGO_VERSION = "0.163.3"
NODE_VERSION = "24.16.0"
TZ = "Europe/Oslo"
@@ -46,20 +43,20 @@ Step 1
"""
```
If your site requires Dart Sass to transpile Sass to CSS, set the `DART_SASS_VERSION` and include the Dart Sass installation in the build step.
If your project requires Dart Sass to transpile Sass to CSS, set the `DART_SASS_VERSION` and include the Dart Sass installation in the build step.
```toml {file="netlify.toml" copy=true}
[build.environment]
DART_SASS_VERSION = "1.101.0"
GO_VERSION = "1.26.4"
HUGO_VERSION = "0.163.2"
HUGO_VERSION = "0.163.3"
NODE_VERSION = "24.16.0"
TZ = "Europe/Oslo"
[build]
publish = "public"
command = """\
curl -sLJO "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" && \
curl -sfLO "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" && \
tar -C "${HOME}/.local" -xf "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" && \
rm "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" && \
export PATH="${HOME}/.local/dart-sass:${PATH}" && \
@@ -69,57 +66,69 @@ Step 1
```
Step 2
: Commit the changes to your local Git repository and push to your GitHub repository.
: In your project configuration, change the location of the image cache to the [`cacheDir`][] as shown below:
{{< code-toggle file=hugo copy=true >}}
[caches.images]
dir = ':cacheDir/images'
{{< /code-toggle >}}
See [configure file caches][] for more information.
Step 3
: Commit the changes to your local Git repository and push to your GitHub repository.
Step 4
: In the upper right corner of the Netlify dashboard, press the **Add new project** button and select “Import an existing project".
![screen capture](netlify-01.png)
Step 4
Step 5
: Connect to GitHub.
![screen capture](netlify-02.png)
Step 5
Step 6
: Press the "Authorize Netlify" button to allow the Netlify application to access your GitHub account.
![screen capture](netlify-03.png)
Step 6
Step 7
: Press the **Configure Netlify on GitHub** button.
![screen capture](netlify-04.png)
Step 7
Step 8
: Select the GitHub account where you want to install the Netlify application.
![screen capture](netlify-05.png)
Step 8
Step 9
: Authorize the Netlify application to access all repositories or only select repositories, then press the Install button.
![screen capture](netlify-06.png)
Your browser will be redirected to the Netlify dashboard.
Step 9
Step 10
: Click on the name of the repository you wish to import.
![screen capture](netlify-07.png)
Step 10
Step 11
: On the "Review configuration" page, enter a project name, leave the settings at their default values, then press the **Deploy** button.
![screen capture](netlify-08.png)
![screen capture](netlify-09.png)
Step 11
Step 12
: When the deployment completes, click on the link to your published site.
![screen capture](netlify-10.png)
In the future, whenever you push a change from your local Git repository, Netlify will rebuild and deploy your site.
[`cacheDir`]: /configuration/all/#cachedir
[configure file caches]: /configuration/caches/
[remote]: https://git-scm.com/docs/git-remote
@@ -1,12 +1,12 @@
---
title: Host on Render
description: Host your site on Render.
description: Host your project on Render.
categories: []
keywords: []
aliases: [/hosting-and-deployment/hosting-on-render/]
---
Use these instructions to enable continuous deployment from a GitHub repository. The same general steps apply if you are using Bitbucket or GitLab for version control.
Use these instructions to enable continuous deployment from a GitHub repository. The same general steps apply for other Git providers such as GitLab or Bitbucket.
{{% include "/_common/gitignore-public.md" %}}
@@ -14,19 +14,19 @@ Use these instructions to enable continuous deployment from a GitHub repository.
Please complete the following tasks before continuing:
1. [Create](https://dashboard.render.com/register) a Render account
1. [Log in](https://dashboard.render.com/login) to your Render account
1. [Create](https://github.com/signup) a GitHub account
1. [Log in](https://github.com/login) to your GitHub account
1. [Create](https://github.com/new) a GitHub repository for your project
1. [Create](https://git-scm.com/docs/git-init) a local Git repository for your project with a [remote][] reference to your GitHub repository
1. Create a Hugo project within your local Git repository and test it with the `hugo server` command
1. Commit the changes to your local Git repository and push to your GitHub repository
1. [Create](https://dashboard.render.com/register) a Render account.
1. [Log in](https://dashboard.render.com/login) to your Render account.
1. [Create](https://github.com/signup) a GitHub account.
1. [Log in](https://github.com/login) to your GitHub account.
1. [Create](https://github.com/new) a GitHub repository for your project.
1. [Create](https://git-scm.com/docs/git-init) a local Git repository for your project with a [remote][] reference to your GitHub repository.
1. Create a Hugo project within your local Git repository and test it with the `hugo server` command.
1. Commit the changes to your local Git repository and push to your GitHub repository.
## Procedure
Step 1
: Create a [Render Blueprint][] in the root of your project.
: Create a `render.yaml` file in the root of your project, adjusting the tool versions and time zone as needed.
```yaml {file="render.yaml" copy=true}
services:
@@ -42,7 +42,7 @@ Step 1
- key: GO_VERSION
value: 1.26.4
- key: HUGO_VERSION
value: 0.163.2
value: 0.163.3
- key: NODE_VERSION
value: 24.16.0
- key: TZ
@@ -57,15 +57,16 @@ Step 2
#------------------------------------------------------------------------------
# @file
# Builds a Hugo site hosted on a Render.
# Builds a Hugo project hosted on Render.
#
# Render automatically installs Node.js dependencies.
# Render automatically installs Node.js and any Node.js dependencies.
#------------------------------------------------------------------------------
# Exit on error, undefined variables, or pipe failures
set -euo pipefail
build_temp_dir=""
# Set the build cache directory
HUGO_CACHEDIR="${PWD}/.cache/hugo"
# Perform cleanup
cleanup() {
@@ -78,112 +79,133 @@ Step 2
trap cleanup EXIT SIGINT SIGTERM
main() {
# Create and move into a temporary directory for downloads
build_temp_dir=$(mktemp -d)
pushd "${build_temp_dir}" > /dev/null
# Export the build cache directory
export HUGO_CACHEDIR
# Create the local tools directory
# Create a temporary directory for downloads
build_temp_dir=$(mktemp -d)
# Create a local tools directory
mkdir -p "${HOME}/.local"
# Install Dart Sass
echo "Installing Dart Sass ${DART_SASS_VERSION}..."
curl -sLJO "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
tar -C "${HOME}/.local" -xf "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
curl -sfL --output-dir "${build_temp_dir}" -O "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
tar -C "${HOME}/.local" -xf "${build_temp_dir}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
export PATH="${HOME}/.local/dart-sass:${PATH}"
# Install Go
echo "Installing Go ${GO_VERSION}..."
curl -sLJO "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz"
tar -C "${HOME}/.local" -xf "go${GO_VERSION}.linux-amd64.tar.gz"
export PATH="${HOME}/.local/go/bin:${PATH}"
if [[ -f "go.mod" ]]; then
echo "Installing Go ${GO_VERSION}..."
curl -sfL --output-dir "${build_temp_dir}" -O "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz"
tar -C "${HOME}/.local" -xf "${build_temp_dir}/go${GO_VERSION}.linux-amd64.tar.gz"
export PATH="${HOME}/.local/go/bin:${PATH}"
fi
# Install Hugo
echo "Installing Hugo ${HUGO_VERSION}..."
curl -sLJO "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-amd64.tar.gz"
curl -sfL --output-dir "${build_temp_dir}" -O "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-amd64.tar.gz"
mkdir -p "${HOME}/.local/hugo"
tar -C "${HOME}/.local/hugo" -xf "hugo_${HUGO_VERSION}_linux-amd64.tar.gz"
tar -C "${HOME}/.local/hugo" -xf "${build_temp_dir}/hugo_${HUGO_VERSION}_linux-amd64.tar.gz"
export PATH="${HOME}/.local/hugo:${PATH}"
# Return to the project root
popd > /dev/null
# Verify installations
echo "Verifying installations..."
echo Dart Sass: "$(sass --version)"
echo Go: "$(go version)"
echo Hugo: "$(hugo version)"
echo Node.js: "$(node --version)"
# Log tool versions
echo "Logging tool versions..."
command -v sass &> /dev/null && echo "Dart Sass: $(sass --version)" || echo "Dart Sass: not installed"
command -v go &> /dev/null && echo "Go: $(go version)" || echo "Go: not installed"
command -v hugo &> /dev/null && echo "Hugo: $(hugo version)" || echo "Hugo: not installed"
command -v node &> /dev/null && echo "Node.js: $(node --version)" || echo "Node.js: not installed"
# Configure Git
echo "Configuring Git..."
git config --global core.quotepath false
if [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then
# Fetch full Git history
if [[ $(git rev-parse --is-shallow-repository) == true ]]; then
echo "Fetching full Git history..."
git fetch --unshallow
fi
# Build the site
echo "Building the site..."
hugo build --gc --minify --baseURL "${RENDER_EXTERNAL_URL}"
# Initialize Git submodules
if [[ -f .gitmodules ]]; then
echo "Initializing Git submodules..."
git submodule update --init --recursive
fi
# Build the project
echo "Building the project..."
hugo build --gc --minify
}
main "$@"
```
Step 3
: Commit the changes to your local Git repository and push to your GitHub repository.
: In your project configuration, change the location of the image cache to the [`cacheDir`][] as shown below:
{{< code-toggle file=hugo copy=true >}}
[caches.images]
dir = ':cacheDir/images'
{{< /code-toggle >}}
See [configure file caches][] for more information.
Step 4
: Commit the changes to your local Git repository and push to your GitHub repository.
Step 5
: On the Render [dashboard][], press the **Add new** button and select "Blueprint" from the drop-down menu.
![screen capture](render-01.png)
Step 5
Step 6
: Press the **GitHub** button to connect to your GitHub account.
![screen capture](render-02.png)
Step 6
Step 7
: Press the **Authorize Render** button to allow the Render application to access your GitHub account.
![screen capture](render-03.png)
Step 7
Step 8
: Select the GitHub account where you want to install the Render application.
![screen capture](render-04.png)
Step 8
Step 9
: Authorize the Render application to access all repositories or only select repositories, then press the **Install** button.
![screen capture](render-05.png)
![screen capture](render-05.png)
Step 9
: On the "Create a new Blueprint Instance in My Workspacee" page, press the **Connect** button to the right of the name of your GitHub repository.
Step 10
: On the "Create a new Blueprint Instance in My Workspace" page, press the **Connect** button to the right of the name of your GitHub repository.
![screen capture](render-06.png)
Step 10
Step 11
: Enter a unique name for your Blueprint, then press the **Deploy Blueprint** button at the bottom of the page.
![screen capture](render-07.png)
Step 11
Step 12
: Wait for the site to build and deploy, then click on the "Resources" link on the left side of the page.
![screen capture](render-08.png)
Step 12
Step 13
: Click on the link to the static site resource.
![screen capture](render-09.png)
Step 13
Step 14
: Click on the link to your published site.
![screen capture](render-10.png)
In the future, whenever you push a change from your local Git repository, Render will rebuild and deploy your site.
[Render Blueprint]: https://render.com/docs/blueprint-spec
[`cacheDir`]: /configuration/all/#cachedir
[configure file caches]: /configuration/caches/
[dashboard]: https://dashboard.render.com/
[remote]: https://git-scm.com/docs/git-remote
@@ -1,6 +1,6 @@
---
title: Host on SourceHut Pages
description: Host your site on SourceHut Pages.
description: Host your project on SourceHut Pages.
categories: []
keywords: []
aliases: [/hosting-and-deployment/hosting-on-sourcehut/]
@@ -1,11 +1,11 @@
---
title: Host on Vercel
description: Host your site on Vercel.
description: Host your project on Vercel.
categories: []
keywords: []
---
Use these instructions to enable continuous deployment from a GitHub repository. The same general steps apply if you are using Bitbucket or GitLab for version control.
Use these instructions to enable continuous deployment from a GitHub repository. The same general steps apply for other Git providers such as GitLab or Bitbucket.
{{% include "/_common/gitignore-public.md" %}}
@@ -13,14 +13,14 @@ Use these instructions to enable continuous deployment from a GitHub repository.
Please complete the following tasks before continuing:
1. [Create](https://vercel.com/signup) a Vercel account
1. [Log in](https://vercel.com/login) to your Vercel account
1. [Create](https://github.com/signup) a GitHub account
1. [Log in](https://github.com/login) to your GitHub account
1. [Create](https://github.com/new) a GitHub repository for your project
1. [Create](https://git-scm.com/docs/git-init) a local Git repository for your project with a [remote][] reference to your GitHub repository
1. Create a Hugo project within your local Git repository and test it with the `hugo server` command
1. Commit the changes to your local Git repository and push to your GitHub repository
1. [Create](https://vercel.com/signup) a Vercel account.
1. [Log in](https://vercel.com/login) to your Vercel account.
1. [Create](https://github.com/signup) a GitHub account.
1. [Log in](https://github.com/login) to your GitHub account.
1. [Create](https://github.com/new) a GitHub repository for your project.
1. [Create](https://git-scm.com/docs/git-init) a local Git repository for your project with a [remote][] reference to your GitHub repository.
1. Create a Hugo project within your local Git repository and test it with the `hugo server` command.
1. Commit the changes to your local Git repository and push to your GitHub repository.
## Procedure
@@ -30,28 +30,37 @@ Step 1
```json {file="vercel.json" copy=true}
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"installCommand": "",
"buildCommand": "chmod a+x build.sh && ./build.sh",
"outputDirectory": "public"
}
```
Step 2
: Create a `build.sh` file in the root of your project.
: Create a `build.sh` file in the root of your project, adjusting the tool versions and time zone as needed.
```sh {file="build.sh" copy=true}
#!/usr/bin/env bash
#------------------------------------------------------------------------------
# @file
# Builds a Hugo site hosted on Vercel.
#
# The Vercel build image automatically installs Node.js dependencies.
# Builds a Hugo project hosted on Vercel.
#------------------------------------------------------------------------------
# Exit on error, undefined variables, or pipe failures
set -euo pipefail
build_temp_dir=""
# Define tool versions
DART_SASS_VERSION=1.101.0
GO_VERSION=1.26.4
HUGO_VERSION=0.163.3
NODE_VERSION=24.16.0
# Set the build time zone
TZ=Europe/Oslo
# Set the build cache directory
HUGO_CACHEDIR="${PWD}/.vercel/cache/hugo"
# Perform cleanup
cleanup() {
@@ -64,127 +73,151 @@ Step 2
trap cleanup EXIT SIGINT SIGTERM
main() {
# Define tool versions
DART_SASS_VERSION=1.101.0
GO_VERSION=1.26.4
HUGO_VERSION=0.163.2
NODE_VERSION=24.16.0
# Export the build time zone
export TZ
# Set the build timezone
export TZ=Europe/Oslo
# Export the build cache directory
export HUGO_CACHEDIR
# Create and move into a temporary directory for downloads
# Create a temporary directory for downloads
build_temp_dir=$(mktemp -d)
pushd "${build_temp_dir}" > /dev/null
# Create the local tools directory
# Create a local tools directory
mkdir -p "${HOME}/.local"
# Install Dart Sass
echo "Installing Dart Sass ${DART_SASS_VERSION}..."
curl -sLJO "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
tar -C "${HOME}/.local" -xf "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
curl -sfL --output-dir "${build_temp_dir}" -O "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
tar -C "${HOME}/.local" -xf "${build_temp_dir}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
export PATH="${HOME}/.local/dart-sass:${PATH}"
# Install Go
echo "Installing Go ${GO_VERSION}..."
curl -sLJO "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz"
tar -C "${HOME}/.local" -xf "go${GO_VERSION}.linux-amd64.tar.gz"
export PATH="${HOME}/.local/go/bin:${PATH}"
if [[ -f "go.mod" ]]; then
echo "Installing Go ${GO_VERSION}..."
curl -sfL --output-dir "${build_temp_dir}" -O "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz"
tar -C "${HOME}/.local" -xf "${build_temp_dir}/go${GO_VERSION}.linux-amd64.tar.gz"
export PATH="${HOME}/.local/go/bin:${PATH}"
fi
# Install Hugo
echo "Installing Hugo ${HUGO_VERSION}..."
curl -sLJO "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-amd64.tar.gz"
curl -sfL --output-dir "${build_temp_dir}" -O "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-amd64.tar.gz"
mkdir -p "${HOME}/.local/hugo"
tar -C "${HOME}/.local/hugo" -xf "hugo_${HUGO_VERSION}_linux-amd64.tar.gz"
tar -C "${HOME}/.local/hugo" -xf "${build_temp_dir}/hugo_${HUGO_VERSION}_linux-amd64.tar.gz"
export PATH="${HOME}/.local/hugo:${PATH}"
# Install Node.js
echo "Installing Node.js ${NODE_VERSION}..."
curl -sLJO "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz"
tar -C "${HOME}/.local" -xf "node-v${NODE_VERSION}-linux-x64.tar.xz"
export PATH="${HOME}/.local/node-v${NODE_VERSION}-linux-x64/bin:${PATH}"
if [[ -f "package-lock.json" ]]; then
echo "Installing Node.js ${NODE_VERSION}..."
curl -sfL --output-dir "${build_temp_dir}" -O "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz"
tar -C "${HOME}/.local" -xf "${build_temp_dir}/node-v${NODE_VERSION}-linux-x64.tar.gz"
export PATH="${HOME}/.local/node-v${NODE_VERSION}-linux-x64/bin:${PATH}"
fi
# Return to the project root
popd > /dev/null
# Verify installations
echo "Verifying installations..."
echo Dart Sass: "$(sass --version)"
echo Go: "$(go version)"
echo Hugo: "$(hugo version)"
echo Node.js: "$(node --version)"
# Log tool versions
echo "Logging tool versions..."
command -v sass &> /dev/null && echo "Dart Sass: $(sass --version)" || echo "Dart Sass: not installed"
command -v go &> /dev/null && echo "Go: $(go version)" || echo "Go: not installed"
command -v hugo &> /dev/null && echo "Hugo: $(hugo version)" || echo "Hugo: not installed"
command -v node &> /dev/null && echo "Node.js: $(node --version)" || echo "Node.js: not installed"
# Configure Git
echo "Configuring Git..."
git config --global core.quotepath false
if [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then
# Fetch full Git history
if [[ $(git rev-parse --is-shallow-repository) == true ]]; then
echo "Fetching full Git history..."
git fetch --unshallow
fi
# Build the site
echo "Building the site..."
hugo build --gc --minify --baseURL "https://${VERCEL_PROJECT_PRODUCTION_URL}"
# Initialize Git submodules
if [[ -f .gitmodules ]]; then
echo "Initializing Git submodules..."
git submodule update --init --recursive
fi
# Install Node.js dependencies
if [[ -f package-lock.json ]]; then
echo "Installing Node.js dependencies..."
npm ci
fi
# Build the project
echo "Building the project..."
hugo build --gc --minify
}
main "$@"
```
Step 3
: Commit the changes to your local Git repository and push to your GitHub repository.
: In your project configuration, change the location of the image cache to the [`cacheDir`][] as shown below:
{{< code-toggle file=hugo copy=true >}}
[caches.images]
dir = ':cacheDir/images'
{{< /code-toggle >}}
See [configure file caches][] for more information.
Step 4
: Commit the changes to your local Git repository and push to your GitHub repository.
Step 5
: In the upper right corner of the Vercel dashboard, press the **Add New** button and select "Project" from the drop down menu.
![screen capture](vercel-01.png)
Step 5
Step 6
: Press the "Continue with GitHub" button.
![screen capture](vercel-02.png)
Step 6
Step 7
: Press the **Authorize Vercel** button to allow the Vercel application to access your GitHub account.
![screen capture](vercel-03.png)
Step 7
Step 8
: Press the **Install** button to install the Vercel application.
![screen capture](vercel-04.png)
Step 8
Step 9
: Select the GitHub account where you want to install the Vercel application.
![screen capture](vercel-05.png)
Step 9
Step 10
: Authorize the Vercel application to access all repositories or only select repositories, then press the **Install** button.
![screen capture](vercel-06.png)
Your browser will be redirected to the Cloudflare dashboard.
Step 10
Step 11
: Press the **Import** button to the right of the name of your GitHub repository.
![screen capture](vercel-07.png)
Step 11
Step 12
: On the "New Project" page, leave the settings at their default values and press the **Deploy** button.
![screen capture](vercel-08.png)
Step 12
Step 13
: When the deployment completes, press the **Continue to Dashboard" button at the bottom of the page.
![screen capture](vercel-09.png)
Step 13
Step 14
: On the "Production Deployment" page, click on the link to your published site.
![screen capture](vercel-10.png)
In the future, whenever you push a change from your local Git repository, Vercel will rebuild and deploy your site.
[`cacheDir`]: /configuration/all/#cachedir
[configure file caches]: /configuration/caches/
[remote]: https://git-scm.com/docs/git-remote
@@ -13,7 +13,7 @@ Modules that need Node packages (e.g. for Tailwind CSS) can declare those depend
Each module declares its Node dependencies in a `package.json` file in its root directory, using the standard `dependencies` and `devDependencies` fields.
<!-- TODO
In the admonition below, remove the reference to v0.159.0 somewhere
In the admonition below, remove the reference to v0.159.0 somewhere
after v0.174.0, 15 minor releases after the improvement.
-->
@@ -37,7 +37,7 @@ project/
```
<!-- TODO
In the admonition below, remove the reference to v0.159.0 somewhere
In the admonition below, remove the reference to v0.159.0 somewhere
after v0.174.0, 15 minor releases after the improvement.
-->
@@ -24,7 +24,7 @@ content/
│ │ ├── auction-1.md
│ │ └── auction-2.md <-- current section: 2023-11
│ ├── 2023-12/
│ │ ├── _index.md
│ │ ├── _index.md
│ │ ├── auction-3.md
│ │ └── auction-4.md
│ ├── _index.md <-- current section: auctions
@@ -35,7 +35,7 @@ content/
│ ├── book-1.md
│ └── book-2.md <-- current section: books
├── films/
│ ├── _index.md <-- current section: films
│ ├── _index.md <-- current section: films
│ ├── film-1.md
│ └── film-2.md <-- current section: films
└── _index.md <-- current section: home
+1 -1
View File
@@ -58,7 +58,7 @@ Use these methods on the `Data` object within a _taxonomy_ template.
: (`page.Taxonomy`) Returns the `Taxonomy` object, consisting of a map of terms and the [weighted pages](g) associated with each term.
```go-html-template
{{ $taxonomyObject := .Data.Terms }}
{{ $taxonomyObject := .Data.Terms }}
```
> [!NOTE]
+1 -1
View File
@@ -24,7 +24,7 @@ content/
│ │ ├── auction-1.md
│ │ └── auction-2.md <-- first section: auctions
│ ├── 2023-12/
│ │ ├── _index.md
│ │ ├── _index.md
│ │ ├── auction-3.md
│ │ └── auction-4.md
│ ├── _index.md <-- first section: auctions
+2 -2
View File
@@ -132,7 +132,7 @@ Use these methods on the `GitInfo` object.
```go-html-template
{{ with .GitInfo }}
{{ range .Ancestors | first 5 }}
{{ range .Ancestors | first 5 }}
{{ .CommitDate.Format "2006-01-02" }}: {{ .Subject }}
{{ end }}
{{ end }}
@@ -142,7 +142,7 @@ Use these methods on the `GitInfo` object.
```go-html-template
{{ with .GitInfo }}
{{ range .Ancestors.Reverse | first 5 }}
{{ range .Ancestors.Reverse | first 5 }}
{{ .CommitDate.Format "2006-01-02" }}: {{ .Subject }}
{{ end }}
{{ end }}
+1 -1
View File
@@ -21,7 +21,7 @@ content/
│ ├── book-2.md <-- kind = page IsBranch = false
│ └── _index.md <-- kind = section IsBranch = true
├── tags
│ ├── fiction
│ ├── fiction
│ │ └── _index.md <-- kind = term IsBranch = true
│ └── _index.md <-- kind = taxonomy IsBranch = true
└── _index.md <-- kind = home IsBranch = true
+2 -2
View File
@@ -24,7 +24,7 @@ content/
│ │ ├── auction-1.md
│ │ └── auction-2.md <-- parent: 2023-11
│ ├── 2023-12/
│ │ ├── _index.md
│ │ ├── _index.md
│ │ ├── auction-3.md
│ │ └── auction-4.md
│ ├── _index.md <-- parent: home
@@ -35,7 +35,7 @@ content/
│ ├── book-1.md
│ └── book-2.md <-- parent: books
├── films/
│ ├── _index.md <-- parent: home
│ ├── _index.md <-- parent: home
│ ├── film-1.md
│ └── film-2.md <-- parent: films
└── _index.md <-- parent: nil
+2 -2
View File
@@ -98,7 +98,7 @@ A file tree:
content/
└── s1/
├── p1/
│ └── index.md
│ └── index.md
└── p2.md
```
@@ -108,7 +108,7 @@ The same content represented as a logical tree:
content/
└── s1/
├── p1
└── p2
└── p2
```
A key difference between these trees is the relative path from p1 to p2:
+1 -1
View File
@@ -25,7 +25,7 @@ content/
│ └── book-2.md
├── films/
│ ├── _index.md
│ ├── film-1.md
│ ├── film-1.md
│ └── film-2.md
└── _index.md
```
+1 -1
View File
@@ -84,7 +84,7 @@ Consider this content structure:
```tree
content/
├── headless/
├── headless/
│ ├── a.jpg
│ ├── b.jpg
│ ├── c.jpg
+1 -1
View File
@@ -32,7 +32,7 @@ baseURL = 'https://example.org/docs/'
Template:
```go-html-template
{{ .Site.Home.Permalink }} → https://example.org/docs/
{{ .Site.Home.Permalink }} → https://example.org/docs/
{{ .Site.Home.RelPermalink }} → /docs/
```
+1 -1
View File
@@ -92,7 +92,7 @@ Some of the methods above are commonly used in a base template as attributes for
```go-html-template
<html
lang="{{ .Site.Language.Locale }}"
lang="{{ .Site.Language.Locale }}"
dir="{{ or .Site.Language.Direction `ltr` }}"
>
```
@@ -1,6 +1,5 @@
---
title: regular expression
reference:
---
A _regular expression_, also known as a _regex_, is a sequence of characters that defines a search pattern. Use the [RE2 syntax][] when defining regular expressions in your templates or in your project configuration.
+2 -2
View File
@@ -28,8 +28,8 @@ Hugo renders this HTML:
```html
<figure class="ma0 w-75">
<a href="https://www.nps.gov/zion/index.htm">
<img
src="/images/examples/zion-national-park.jpg"
<img
src="/images/examples/zion-national-park.jpg"
alt="A photograph of Zion National Park"
>
</a>
+5 -5
View File
@@ -113,9 +113,9 @@ In the example above:
Hugo renders the above to:
```html {trim=false}
<h2>my page title</h2>
```
### Whitespace
@@ -194,7 +194,7 @@ You can split a template action over two or more lines. For example, these are e
```go-html-template
{{ $v := or $arg1 $arg2 }}
{{ $v := or
{{ $v := or
$arg1
$arg2
}}
@@ -225,8 +225,8 @@ Other than using the `nil` keyword in comparisons, you may not use it as an argu
These, on the other hand, are invalid:
```go-html-template
{{ $a := nil }}
{{ add 3 nil }}
{{ $a := nil }}
{{ add 3 nil }}
{{ nil | print}}
```
+1 -1
View File
@@ -85,7 +85,7 @@ For example, the _base_ template below calls the [`partial`][] function to inclu
</header>
<main>
{{ block "main" . }}
This will be replaced with content from the
This will be replaced with content from the
corresponding "define" action found in the template
to which this base template is applied.
{{ end }}
@@ -36,7 +36,7 @@ The result will look something like this:
```text
Template Metrics:
cumulative average maximum cache percent cached total
cumulative average maximum cache percent cached total
duration duration duration potential cached count count template
---------- -------- -------- --------- ------- ------ ----- --------
36.037476822s 135.990478ms 225.765245ms 11 0 0 265 _partials/head.html
+1 -1
View File
@@ -3,7 +3,7 @@
command = "npm ls && hugo --gc --minify"
[build.environment]
HUGO_VERSION = "0.163.2"
HUGO_VERSION = "0.163.3"
[context.production.environment]
HUGO_ENV = "production"