How to use the container Hugo version with One Cli

2019-08-28 22:04发布

In the Netlify CMS community chat, the question keeps coming up how to manage the Hugo version without a bin folder and executable.

The one-click-hugo-cms example is a deploy to generate a Hugo static site and use Netlify CMS to be able to add posts for the site.

The Issue: The site setup uses a bin folder to store the Hugo executable for simplicity, but the developer wants to use a different version of Hugo and keep it up to date without having to keep copying new executables to the Hugo bin folder.

1条回答
我只想做你的唯一
2楼-- · 2019-08-28 22:18

The bin folder for Hugo is NOT required. Netlify manages a Hugo version install in the container based on the environment variable (HUGO_VERSION) when there is a build.

Basically follow these steps:

  • Remove the bin folder and executable out of the project
  • Change the command to the bin path and call it globally
  • Let Netlify know what version you want to use in the netlify.toml

Remove the bin path

Edit this line

const hugoBin = `./bin/hugo.${process.platform === "win32" ? "exe" : process.platform}`;

to be

const hugoBin = 'hugo';

netlify.toml

[build]
  command = "yarn build"
  publish = "dist"
[build.environment]
  YARN_VERSION = "1.3.2"
  HUGO_VERSION = "0.36.1"

[context.deploy-preview]
  command = "yarn build-preview"

NOTES:

查看更多
登录 后发表回答