【问题标题】:How to use the container Hugo version with One Click Netlify CMS example如何通过 One Click Netlify CMS 示例使用容器 Hugo 版本
【发布时间】:2018-08-06 13:09:51
【问题描述】:

Netlify CMS community 聊天中,不断出现的问题是如何在没有 bin 文件夹和可执行文件的情况下管理 Hugo 版本。

one-click-hugo-cms 示例是用于生成 Hugo 静态站点并使用 Netlify CMS 为该站点添加帖子的部署。

问题:为简单起见,站点设置使用 bin 文件夹来存储 Hugo 可执行文件,但开发人员希望使用不同版本的 Hugo 并使其保持最新状态,而无需继续复制将新的可执行文件添加到 Hugo bin 文件夹中。

【问题讨论】:

    标签: hugo netlify netlify-cms


    【解决方案1】:

    Hugo 的 bin 文件夹不需要。 Netlify 在构建时根据环境变量(HUGO_VERSION)管理容器中的 Hugo 版本安装。

    基本上遵循以下步骤:

    • 从项目中删除 bin 文件夹和可执行文件
    • 把命令改成bin路径,全局调用
    • netlify.toml 中让 Netlify 知道您要使用的版本

    删除 bin 路径

    编辑这一行

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

    成为

    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"
    

    注意事项:

    【讨论】:

    • 请帮助我了解如何删除 bin 文件夹?我应该在添加到 git commit 时跳过还是使用上面 sn-p 中给出的命令集? M 使用 Windows 10 机器。
    • 解决方案工作后。从 git 存储库中删除它,因为不再需要这些文件。当然,您需要遵循 Hugo on Windows 的安装文档才能使其在本地工作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-11
    • 1970-01-01
    • 2018-06-30
    • 1970-01-01
    • 2017-10-31
    • 2020-07-18
    相关资源
    最近更新 更多