Skip to content

Commit 8ecbc98

Browse files
committed
content: Update hosting workflow files
- Amplify - GitHub Pages - GitLab Pages - Netlify
1 parent 57fd362 commit 8ecbc98

File tree

5 files changed

+176
-169
lines changed

5 files changed

+176
-169
lines changed

‎content/en/functions/css/Sass.md‎

Lines changed: 14 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -122,83 +122,33 @@ Run `hugo env` to list the active transpilers.
122122
123123
### Installing in a production environment
124124

125-
For [CI/CD](g) deployments (e.g., GitHub Pages, GitLab Pages, Netlify, etc.) you must edit the workflow to install Dart Sass before Hugo builds the site[^2]. Some providers allow you to use one of the package managers above, or you can download and extract one of the prebuilt binaries.
125+
To use Dart Sass with Hugo on a CI/CD platform like GitHub Pages, GitLab Pages, or Netlify, you typically must modify your build workflow to install Dart Sass before the Hugo site build begins. This is because these platforms don't have Dart Sass pre-installed, and Hugo needs it to process your Sass files.
126126

127-
[^2]: You do not have to do this if (a) you have not modified the assets cache location, and (b) you have not set `useResourceCacheWhen` to `never` in your [site configuration], and (c) you add and commit your `resources` directory to your repository.
127+
There's one key exception where you can skip this step: you have committed your `resources` directory to your repository. This is only possible if:
128128

129-
#### GitHub Pages
129+
- You have not changed Hugo's default asset cache location.
130+
- You have not set [`useResourceCacheWhen`] to never in your sites configuration.
130131

131-
To install Dart Sass for your builds on GitHub Pages, add this step to the GitHub Pages workflow file:
132+
By committing the `resources` directory, you're providing the pre-built CSS files directly to your CI/CD service, so it doesn't need to run the Sass compilation itself.
132133

133-
```yaml
134-
- name: Install Dart Sass
135-
run: sudo snap install dart-sass
136-
```
137-
138-
#### GitLab Pages
139-
140-
To install Dart Sass for your builds on GitLab Pages, the `.gitlab-ci.yml` file should look something like this:
141-
142-
```yaml
143-
variables:
144-
HUGO_VERSION: 0.148.0
145-
DART_SASS_VERSION: 1.89.2
146-
GIT_DEPTH: 0
147-
GIT_STRATEGY: clone
148-
GIT_SUBMODULE_STRATEGY: recursive
149-
TZ: America/Los_Angeles
150-
image:
151-
name: golang:1.20-buster
152-
pages:
153-
script:
154-
# Install Dart Sass
155-
- curl -LJO https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz
156-
- tar -xf dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz
157-
- cp -r dart-sass/* /usr/local/bin
158-
- rm -rf dart-sass*
159-
# Install Hugo
160-
- curl -LJO https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb
161-
- apt install -y ./hugo_extended_${HUGO_VERSION}_linux-amd64.deb
162-
- rm hugo_extended_${HUGO_VERSION}_linux-amd64.deb
163-
# Build
164-
- hugo --gc --minify
165-
artifacts:
166-
paths:
167-
- public
168-
rules:
169-
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
170-
```
134+
For examples of how to install Dart Sass in a production environment, see the following workflow files:
171135

172-
#### Netlify
173-
174-
To install Dart Sass for your builds on Netlify, the `netlify.toml` file should look something like this:
175-
176-
```toml
177-
[build.environment]
178-
HUGO_VERSION = "0.148.0"
179-
DART_SASS_VERSION = "1.89.2"
180-
NODE_VERSION = "22"
181-
TZ = "America/Los_Angeles"
182-
183-
[build]
184-
publish = "public"
185-
command = """\
186-
curl -LJO https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz && \
187-
tar -xf dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz && \
188-
rm dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz && \
189-
export PATH=/opt/build/repo/dart-sass:$PATH && \
190-
hugo --gc --minify \
191-
"""
192-
```
136+
- [GitHub Pages]
137+
- [GitLab Pages]
138+
- [Netlify]
193139

140+
[`publishDir`]: /configuration/all/#publishdir
141+
[`useResourceCacheWhen`]: /configuration/build/#useresourcecachewhen
194142
[brew.sh]: https://brew.sh/
195143
[chocolatey.org]: https://community.chocolatey.org/packages/sass
196144
[dart sass]: https://sass-lang.com/dart-sass
145+
[GitHub Pages]: /host-and-deploy/host-on-github-pages/#step-7
146+
[GitLab Pages]: /host-and-deploy/host-on-gitlab-pages/#configure-gitlab-cicd
197147
[libsass]: https://sass-lang.com/libsass
148+
[Netlify]: /host-and-deploy/host-on-gitlab-pages/#configure-gitlab-cicd
198149
[prebuilt binaries]: https://github.com/sass/dart-sass/releases/latest
199150
[scoop.sh]: https://scoop.sh/#/apps?q=sass
200151
[site configuration]: /configuration/build/
201152
[snap package]: /installation/linux/#snap
202153
[snapcraft.io]: https://snapcraft.io/dart-sass
203154
[starter workflow]: https://github.com/actions/starter-workflows/blob/main/pages/hugo.yml
204-
[`publishDir`]: /configuration/all/#publishdir

‎content/en/host-and-deploy/host-on-aws-amplify/index.md‎

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -44,50 +44,61 @@ version: 1
4444
env:
4545
variables:
4646
# Application versions
47-
DART_SASS_VERSION: 1.89.2
48-
GO_VERSION: 1.24.2
49-
HUGO_VERSION: 0.148.0
47+
DART_SASS_VERSION: 1.90.0
48+
GO_VERSION: 1.24.5
49+
HUGO_VERSION: 0.148.2
5050
# Time zone
51-
TZ: America/Los_Angeles
51+
TZ: Europe/Oslo
5252
# Cache
5353
HUGO_CACHEDIR: ${PWD}/.hugo
5454
NPM_CONFIG_CACHE: ${PWD}/.npm
5555
frontend:
5656
phases:
5757
preBuild:
5858
commands:
59+
# Create directory for user-specific executable files
60+
- echo "Creating directory for user-specific executable files..."
61+
- mkdir -p "${HOME}/.local"
62+
5963
# Install Dart Sass
60-
- curl -LJO https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz
61-
- sudo tar -C /usr/local/bin -xf dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz
62-
- rm dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz
63-
- export PATH=/usr/local/bin/dart-sass:$PATH
64+
- echo "Installing Dart Sass ${DART_SASS_VERSION}..."
65+
- curl -sLJO "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
66+
- tar -C "${HOME}/.local" -xf "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
67+
- rm "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
68+
- export PATH="${HOME}/.local/dart-sass:${PATH}"
6469

6570
# Install Go
66-
- curl -LJO https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz
67-
- sudo tar -C /usr/local -xf go${GO_VERSION}.linux-amd64.tar.gz
68-
- rm go${GO_VERSION}.linux-amd64.tar.gz
69-
- export PATH=/usr/local/go/bin:$PATH
71+
- echo "Installing Go ${GO_VERSION}..."
72+
- curl -sLJO "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz"
73+
- tar -C "${HOME}/.local" -xf "go${GO_VERSION}.linux-amd64.tar.gz"
74+
- rm "go${GO_VERSION}.linux-amd64.tar.gz"
75+
- export PATH="${HOME}/.local/go/bin:${PATH}"
7076

7177
# Install Hugo
72-
- curl -LJO https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz
73-
- sudo tar -C /usr/local/bin -xf hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz
74-
- rm hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz
75-
- export PATH=/usr/local/bin:$PATH
76-
77-
# Check installed versions
78-
- go version
79-
- hugo version
80-
- node -v
81-
- npm -v
82-
- sass --embedded --version
83-
84-
# Install Node.JS dependencies
78+
- echo "Installing Hugo ${HUGO_VERSION}..."
79+
- curl -sLJO "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
80+
- mkdir "${HOME}/.local/hugo"
81+
- tar -C "${HOME}/.local/hugo" -xf "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
82+
- rm "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
83+
- export PATH="${HOME}/.local/hugo:${PATH}"
84+
85+
# Verify installations
86+
- echo "Verifying installations..."
87+
- "echo Dart Sass: $(sass --version)"
88+
- "echo Go: $(go version)"
89+
- "echo Hugo: $(hugo version)"
90+
- "echo Node.js: $(node --version)"
91+
92+
# Install Node.js dependencies
93+
- echo "Installing Node.js dependencies..."
8594
- "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci --prefer-offline || true"
8695

87-
# https://github.com/gohugoio/hugo/issues/9810
88-
- git config --add core.quotepath false
96+
# Configure Git
97+
- echo "Configuring Git..."
98+
- git config core.quotepath false
8999
build:
90100
commands:
101+
- echo "Building site..."
91102
- hugo --gc --minify
92103
artifacts:
93104
baseDirectory: public

‎content/en/host-and-deploy/host-on-github-pages/index.md‎

Lines changed: 48 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -73,90 +73,97 @@ touch .github/workflows/hugo.yaml
7373
Copy and paste the YAML below into the file you created. Change the branch name and Hugo version as needed.
7474

7575
```yaml {file=".github/workflows/hugo.yaml" copy=true}
76-
# Sample workflow for building and deploying a Hugo site to GitHub Pages
77-
name: Deploy Hugo site to Pages
78-
76+
name: Build and deploy Hugo site to GitHub Pages
7977
on:
80-
# Runs on pushes targeting the default branch
8178
push:
8279
branches:
8380
- main
84-
85-
# Allows you to run this workflow manually from the Actions tab
8681
workflow_dispatch:
87-
88-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
8982
permissions:
9083
contents: read
9184
pages: write
9285
id-token: write
93-
94-
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
95-
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
9686
concurrency:
97-
group: "pages"
87+
group: pages
9888
cancel-in-progress: false
99-
100-
# Default to bash
10189
defaults:
10290
run:
103-
# GitHub-hosted runners automatically enable `set -eo pipefail` for Bash shells.
10491
shell: bash
105-
10692
jobs:
107-
# Build job
10893
build:
10994
runs-on: ubuntu-latest
11095
env:
111-
DART_SASS_VERSION: 1.89.2
112-
HUGO_VERSION: 0.148.0
113-
HUGO_ENVIRONMENT: production
114-
TZ: America/Los_Angeles
96+
DART_SASS_VERSION: 1.90.0
97+
GO_VERSION: 1.24.5
98+
HUGO_VERSION: 0.148.2
99+
NODE_VERSION: 22.18.0
100+
TZ: Europe/Oslo
115101
steps:
116-
- name: Install Hugo CLI
117-
run: |
118-
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb
119-
sudo dpkg -i ${{ runner.temp }}/hugo.deb
120-
- name: Install Dart Sass
121-
run: |
122-
wget -O ${{ runner.temp }}/dart-sass.tar.gz https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz
123-
tar -xf ${{ runner.temp }}/dart-sass.tar.gz --directory ${{ runner.temp }}
124-
mv ${{ runner.temp }}/dart-sass/ /usr/local/bin
125-
echo "/usr/local/bin/dart-sass" >> $GITHUB_PATH
126102
- name: Checkout
127103
uses: actions/checkout@v4
128104
with:
129105
submodules: recursive
130106
fetch-depth: 0
107+
- name: Setup Go
108+
uses: actions/setup-go@v5
109+
with:
110+
go-version: ${{ env.GO_VERSION }}
111+
cache: false
112+
- name: Setup Node.js
113+
uses: actions/setup-node@v4
114+
with:
115+
node-version: ${{ env.NODE_VERSION }}
131116
- name: Setup Pages
132117
id: pages
133118
uses: actions/configure-pages@v5
119+
- name: Create directory for user-specific executable files
120+
run: |
121+
mkdir -p "${HOME}/.local"
122+
- name: Install Dart Sass
123+
run: |
124+
curl -sLJO "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
125+
tar -C "${HOME}/.local" -xf "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
126+
rm "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
127+
echo "${HOME}/.local/dart-sass" >> "${GITHUB_PATH}"
128+
- name: Install Hugo
129+
run: |
130+
curl -sLJO "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
131+
mkdir "${HOME}/.local/hugo"
132+
tar -C "${HOME}/.local/hugo" -xf "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
133+
rm "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
134+
echo "${HOME}/.local/hugo" >> "${GITHUB_PATH}"
135+
- name: Verify installations
136+
run: |
137+
echo "Dart Sass: $(sass --version)"
138+
echo "Go: $(go version)"
139+
echo "Hugo: $(hugo version)"
140+
echo "Node.js: $(node --version)"
134141
- name: Install Node.js dependencies
135-
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
136-
- name: Cache Restore
142+
run: |
143+
[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true
144+
- name: Configure Git
145+
run: |
146+
git config core.quotepath false
147+
- name: Cache restore
137148
id: cache-restore
138149
uses: actions/cache/restore@v4
139150
with:
140-
path: |
141-
${{ runner.temp }}/hugo_cache
151+
path: ${{ runner.temp }}/hugo_cache
142152
key: hugo-${{ github.run_id }}
143153
restore-keys:
144154
hugo-
145-
- name: Configure Git
146-
run: git config core.quotepath false
147-
- name: Build with Hugo
155+
- name: Build the site
148156
run: |
149157
hugo \
150158
--gc \
151159
--minify \
152160
--baseURL "${{ steps.pages.outputs.base_url }}/" \
153161
--cacheDir "${{ runner.temp }}/hugo_cache"
154-
- name: Cache Save
162+
- name: Cache save
155163
id: cache-save
156164
uses: actions/cache/save@v4
157165
with:
158-
path: |
159-
${{ runner.temp }}/hugo_cache
166+
path: ${{ runner.temp }}/hugo_cache
160167
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
161168
- name: Upload artifact
162169
uses: actions/upload-pages-artifact@v3

0 commit comments

Comments
 (0)