Netlify中Jekyll的上下文变量
要检测生成,请等待Netlify中Jekyll的上下文变量,jekyll,netlify,Jekyll,Netlify,要检测生成,请等待Jekyll_ENV变量: Netlify设置上下文变量: 因此,Jekyll没有看到build iNetlify的上下文变量与Jekyll的Jekyll_ENV不相同。因此,您需要分别设置JEKYLL_ENV,可能使用?类似的方法可能会奏效: # this will be the default for every branch other than the production branch [build.environment] JEKYLL_ENV="develop
Jekyll_ENV
变量:
Netlify设置上下文
变量:
因此,Jekyll没有看到build iNetlify的
上下文
变量与Jekyll的Jekyll_ENV
不相同。因此,您需要分别设置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"
我成功地测试了三种不同的方法来设置
JEKYLL_ENV
环境变量,然后可以在液体模板中以JEKYLL.environment
的形式访问该变量:
netlify.toml
:直接在build命令中设置环境变量
# 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
:在build命令中设置环境变量
JEKYLL_ENV="netlify" jekyll build
我也有同样的问题,通过在Netlify设置页面的环境变量中添加
JEKYLL_ENV
对其进行排序。无需添加toml文件。我尝试了前半部分[build.environment]
JEKYLL_ENV=“netlify”
并且它可以工作,尽管我预计它会引发语法错误,因为通常的语法是带花括号的[build]
environment={JEKYLL_ENV=“netlify”}
。