创建要在部署中设置的变量

Create variable to be set in deployment

如何在 jekyll 中为 link 设置一个由其部署环境决定的变量?

如果我在沙盒中部署,我希望 {{site.REDIRECT_LINK}} 设置为与在生产中部署时不同的 URL。

我假设我在 _config 文件中设置了它,但是我需要为 docker 设置什么吗?

您需要在配置文件中设置与您的环境名称匹配的变量:

staging:
  redirect_link: http://staging.example.com
production:
  redirect_link: http://example.com

那你就可以打电话{{ site[jekyll.environment].redirect_link }}了。如果您在暂存环境中构建,您将获得“http://staging.example.com”