在 netlify 使用最新版本的 hugo 和 go 构建网站

Nov 29, 2019 • 预计阅读时间 2 分钟

如果你使用 hugo 构建网站,那么一定知道 hugo 最近新发布了 v0.60 版本
hugo v0.60 开始,更换了默认的 markdown 渲染内核,使用更快的 goldmark
默认设置下 netlify 使用的是保守设置,不会使用最新版本的 go 和 hugo 来构建网站。
可以增加两个环境变量来覆盖 netlify 的默认设置:

HUGO_VERSION0.60.0
GO_VERSION1.13.4

分享一个 hugo 优化页面的设置:--gc --minify
--gc 是在构建网站完成以后清理缓存
--minify 是最小化所有支持格式的输出文件,比如生成的 html 文件

清除缓存再重新构建网站:

9:56:58 AM: Build ready to start
9:57:00 AM: build-image version: 9cade8af58c2cf3a17a1e9433d2e979149488837
9:57:00 AM: build-image tag: v3.3.5
9:57:00 AM: buildbot version: 1c753eef258dfb3c0efc0675c36d881d135e648f
9:57:01 AM: Fetching cached dependencies
9:57:01 AM: Starting to download cache of 254.9KB
9:57:01 AM: Finished downloading cache in 96.48083ms
9:57:01 AM: Starting to extract cache
9:57:01 AM: Failed to fetch cache, continuing with build
9:57:01 AM: Starting to prepare the repo for build
9:57:01 AM: No cached dependencies found. Cloning fresh repo
9:57:01 AM: git clone https://github.com/cntrump/lvv-pages
9:57:02 AM: Preparing Git Reference refs/heads/master
9:57:03 AM: Starting build script
9:57:03 AM: Installing dependencies
9:57:05 AM: v10.17.0 is already installed.
9:57:05 AM: Now using node v10.17.0 (npm v6.11.3)
9:57:05 AM: Attempting ruby version 2.6.2, read from environment
9:57:07 AM: Using ruby version 2.6.2
9:57:07 AM: Using PHP version 5.6
9:57:07 AM: Installing Hugo 0.60.0
9:57:09 AM: Hugo Static Site Generator v0.60.0-F2DEA9B0/extended linux/amd64 BuildDate: 2019-11-27T10:17:14Z
9:57:09 AM: Started restoring cached go cache
9:57:09 AM: Finished restoring cached go cache
9:57:09 AM: Installing Go version 1.13.4
9:57:17 AM: unset GOOS;
9:57:17 AM: unset GOARCH;
9:57:17 AM: export GOROOT='/opt/buildhome/.gimme_cache/versions/go1.13.4.linux.amd64';
9:57:17 AM: export PATH="/opt/buildhome/.gimme_cache/versions/go1.13.4.linux.amd64/bin:${PATH}";
9:57:17 AM: go version >&2;
9:57:17 AM: export GIMME_ENV="/opt/buildhome/.gimme_cache/env/go1.13.4.linux.amd64.env"
9:57:17 AM: go version go1.13.4 linux/amd64
9:57:17 AM: Installing missing commands
9:57:17 AM: Verify run directory
9:57:17 AM: Executing user command: hugo
9:57:17 AM: Building sites …
9:57:18 AM:                   | EN
9:57:18 AM: +------------------+
9:57:18 AM: ----+
9:57:18 AM:   Pages            | 40
9:57:18 AM:   Paginator pages  |  3
9:57:18 AM:   Non-page files   |  8
9:57:18 AM:   Static files     |  6
9:57:18 AM:   Processed images |  0
9:57:18 AM:   Aliases          |  1
9:57:18 AM:   Sitemaps         |  1
9:57:18 AM:   Cleaned          |  0
9:57:18 AM: Total in 212 ms
9:57:18 AM: Skipping functions preparation step: no functions directory set
9:57:18 AM: Caching artifacts
9:57:18 AM: Started saving pip cache
9:57:18 AM: Finished saving pip cache
9:57:18 AM: Started saving emacs cask dependencies
9:57:18 AM: Finished saving emacs cask dependencies
9:57:18 AM: Started saving maven dependencies
9:57:18 AM: Finished saving maven dependencies
9:57:18 AM: Started saving boot dependencies
9:57:18 AM: Finished saving boot dependencies
9:57:18 AM: Started saving go dependencies
9:57:20 AM: Finished saving go dependencies
9:57:22 AM: Build script success
9:57:22 AM: Starting to deploy site from 'public'
9:57:22 AM: Creating deploy tree 
9:57:23 AM: 37 new files to upload
9:57:23 AM: 0 new functions to upload
9:57:24 AM: Starting post processing
9:57:28 AM: Post processing done
9:57:28 AM: Site is live
9:57:59 AM: Finished processing build request in 58.835905399s
Hugo
版权声明:如果转发请带上本文链接和注明来源。

lvv.me

iOS/macOS Developer

视网膜屏幕下像素对齐计算方法

制作一个极速 Hugo 主题