Jekyll检测到构建,然后等待JEKYLL_ENV
变量:https://jekyllrb.com/docs/configuration/environments/
Netlify设置CONTEXT
变量:https://www.netlify.com/docs/continuous-deployment/?_ga=2.28134843.62454114.1555938051-984068889.1555938051#environment-variables
结果Jekyll没有看到我的建物
答案 0 :(得分:0)
Netlify的CONTEXT
变量不能与Jekyll的JEKYLL_ENV
相同。因此,您可能想单独使用netlify.toml来设置JEKYLL_ENV
?这样的事情可能会起作用:
# this will be the default for every branch other than the production branch
[build.environment]
JEKYLL_ENV="development"
# only for production branch, override to production
[context.production.environment]
JEKYLL_ENV="production"
答案 1 :(得分:0)
我成功地测试了三种不同的设置JEKYLL_ENV
环境变量的方法,然后可以在Liquid模板中以jekyll.environment
的形式对其进行访问:
netlify.toml
:直接在构建命令中设置环境变量
# global context
[build]
publish = "_site/"
command = "JEKYLL_ENV=\"netlify\" jekyll build"
netlify.toml
:设置构建环境
# global context
[build]
publish = "_site/"
command = "jekyll build"
environment = { JEKYLL_ENV = "netlify" }
netlify.toml
:运行自定义构建脚本
# global context
[build]
publish = "_site/"
command = "sh netlify.sh"
netlify.sh
:在构建命令中设置环境变量
JEKYLL_ENV="netlify" jekyll build
答案 2 :(得分:0)
我遇到了同样的问题,并通过在Netlify设置页面的环境变量中添加JEKYLL_ENV
对其进行了排序。无需添加toml文件。