创建要在部署中设置的变量 [英] Create variable to be set in deployment
问题描述
如何在jekyll中为链接设置变量,该变量将由其所部署的环境决定?
How do I set a variable in jekyll for a link that will be determined by the environment that it's deployed in?
即
如果我在沙箱中进行部署,我希望将{{site.REDIRECT_LINK}}
设置为与在生产环境中部署时不同的URL.
If I deploy in sandbox I want {{site.REDIRECT_LINK}}
to be set to a different URL than when it's deployed in production.
我假设我在_config
文件中进行了设置,但是我需要为docker进行设置吗?
I'm assuming I set it in the _config
file, but is there anything I need to set up for docker?
推荐答案
您需要在配置文件中设置与您的环境名称匹配的变量:
You'll need to set variables in your config file that match your environment names:
staging:
redirect_link: http://staging.example.com
production:
redirect_link: http://example.com
然后您可以呼叫{{ site[jekyll.environment].redirect_link }}
.如果您在暂存环境中进行构建,则将获得"http://staging.example.com"
Then you can call {{ site[jekyll.environment].redirect_link }}
. If you are building in your staging environment you will get "http://staging.example.com"
这篇关于创建要在部署中设置的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!