如何在Netlify构建中更换Hugo版本(测试v0.32新版本)
Hey folks, let's break down how to test the new Hugo 0.32 version on Netlify without any headaches. Here are my go-to methods:
Method 1: Set an Environment Variable in Netlify Dashboard
This is the quickest way to switch versions for your existing site:
- Head over to your Netlify site's admin panel, navigate to Settings > Build & deploy > Environment
- Click "Add a variable", set the key to
HUGO_VERSIONand the value to0.32 - Trigger a new build (either by pushing a commit or using the "Trigger deploy" button in the Deploys tab)
Netlify will automatically download and use Hugo 0.32 for the build process.
Method 2: Configure via netlify.toml (Persistent Setup)
If you want this version setting to live in your codebase (so everyone on your team uses the same version), add this to your project's netlify.toml file:
[build.environment] HUGO_VERSION = "0.32"
Commit this change to your repo, push it, and Netlify will pick up the version from the config during the next build.
Method 3: Test Locally with Netlify CLI
Before pushing to production, it's smart to test the build locally to catch issues early:
- Install the Netlify CLI if you haven't already:
npm install -g netlify-cli - Create a
.envfile in your project root and add:HUGO_VERSION=0.32 - Run
netlify buildin your terminal—this will replicate Netlify's build environment locally using Hugo 0.32
A quick note: If you run into any compatibility issues with your site and Hugo 0.32, just revert the HUGO_VERSION value to your previous working version and redeploy.
内容的提问来源于stack exchange,提问作者talves

