Skip to content

Commit aac7862

Browse files
lucperkinsk8s-ci-robot
authored andcommitted
Upgrade Hugo to 0.52 (kubernetes#11552)
* Update Hugo version and apply HTML minification to production builds * Use full flag names for clarity * Remove Hugo installation logic out of Travis config and into Makefile * Add Hugo version checking script * Fix Netlify config version
1 parent 9c1248e commit aac7862

File tree

5 files changed

+37
-14
lines changed

5 files changed

+37
-14
lines changed

.travis.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ language: go
22
go:
33
- 1.10.2
44

5-
env:
6-
- HUGO_VERSION=0.49
7-
85
jobs:
96
include:
107
- name: "Testing examples"
@@ -26,9 +23,6 @@ jobs:
2623
- go test -v k8s.io/website/content/en/examples
2724
- name: "Hugo build"
2825
install:
29-
- curl -L https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-64bit.tar.gz | tar -xz
30-
- mkdir -p ${TRAVIS_HOME}/bin
31-
- mv hugo ${TRAVIS_HOME}/bin
32-
- export PATH=${TRAVIS_HOME}/bin:$PATH
26+
- make travis-hugo-build
3327
script:
3428
- hugo

Makefile

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
DOCKER = docker
2-
HUGO_VERSION = 0.49
2+
HUGO_VERSION = 0.52
33
DOCKER_IMAGE = kubernetes-hugo
44
DOCKER_RUN = $(DOCKER) run --rm --interactive --tty --volume $(CURDIR):/src
55
NODE_BIN = node_modules/.bin
@@ -13,20 +13,20 @@ help: ## Show this help.
1313
all: build ## Build site with production settings and put deliverables in ./public
1414

1515
build: ## Build site with production settings and put deliverables in ./public
16-
hugo
16+
hugo --minify
1717

1818
build-preview: ## Build site with drafts and future posts enabled
19-
hugo -D -F
19+
hugo --buildDrafts --buildFuture
2020

2121
functions-build:
2222
$(NETLIFY_FUNC) build functions-src
2323

2424
check-headers-file:
2525
scripts/check-headers-file.sh
2626

27-
production-build: build check-headers-file ## Build the production site and ensure that noindex headers aren't added
27+
production-build: check-hugo-versions build check-headers-file ## Build the production site and ensure that noindex headers aren't added
2828

29-
non-production-build: ## Build the non-production site, which adds noindex headers to prevent indexing
29+
non-production-build: check-hugo-versions ## Build the non-production site, which adds noindex headers to prevent indexing
3030
hugo --enableGitInfo
3131

3232
sass-build:
@@ -36,7 +36,7 @@ sass-develop:
3636
scripts/sass.sh develop
3737

3838
serve: ## Boot the development server.
39-
hugo server --ignoreCache --disableFastRender --buildFuture
39+
hugo server --ignoreCache --buildFuture
4040

4141
docker-image:
4242
$(DOCKER) build . --tag $(DOCKER_IMAGE) --build-arg HUGO_VERSION=$(HUGO_VERSION)
@@ -46,3 +46,13 @@ docker-build:
4646

4747
docker-serve:
4848
$(DOCKER_RUN) -p 1313:1313 $(DOCKER_IMAGE) hugo server --buildFuture --bind 0.0.0.0
49+
50+
# This command is used only by Travis CI; do not run this locally
51+
travis-hugo-build:
52+
curl -L https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-64bit.tar.gz | tar -xz
53+
mkdir -p ${TRAVIS_HOME}/bin
54+
mv hugo ${TRAVIS_HOME}/bin
55+
export PATH=${TRAVIS_HOME}/bin:$PATH
56+
57+
check-hugo-versions:
58+
scripts/hugo-version-check.sh $(HUGO_VERSION)

config.toml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ title = "Kubernetes"
44
defaultContentLanguage = "en"
55
defaultContentLanguageInSubdir = false
66
enableRobotsTXT = true
7+
disableBrowserError = true
78

89
disableKinds = ["taxonomy", "taxonomyTerm"]
910

netlify.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ functions = "functions"
77
command = "make non-production-build"
88

99
[build.environment]
10-
HUGO_VERSION = "0.49"
10+
HUGO_VERSION = "0.52"
1111

1212
[context.production.environment]
1313
HUGO_BASEURL = "https://kubernetes.io/"

scripts/hugo-version-check.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
MAIN_HUGO_VERSION=$1
4+
NETLIFY_HUGO_VERSION=$(cat netlify.toml | grep HUGO_VERSION | awk '{ print $3 }' | tr -d '"')
5+
6+
echo ${NETLIFY_HUGO_VERSION}
7+
8+
if [[ ${MAIN_HUGO_VERSION} != ${NETLIFY_HUGO_VERSION} ]]; then
9+
echo """
10+
[FAILURE] The Hugo version set in the Makefile is ${MAIN_HUGO_VERSION} while the version in netlify.toml is ${NETLIFY_HUGO_VERSION}
11+
[FAILURE] Please update these versions so that they are same (consider the higher of the two versions as canonical).
12+
"""
13+
exit 1
14+
else
15+
echo "[SUCCESS] The Hugo versions match between the Makefile and netlify.toml"
16+
exit 0
17+
fi
18+

0 commit comments

Comments
 (0)