Is there a way I can use one my bash environment variable (say $FOO
) in my Jekyll's _config.yml
file?
I've tried using:
foo = <%= ENV['FOO'] %>
But it didn't work as the Ruby code wasn't interpreted.
Versions used:
For Applications, including Web Applications, On Windows: If you want environmental variables to be expanded your application will need to do that itself. A common way of doing this is to use the cmd syntax %variable% and then using Environment. ExpandEnvironmentVariables to expand them.
In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables. Click New to create a new environment variable. Click Edit to modify an existing environment variable.
The . env file contains the individual user environment variables that override the variables set in the /etc/environment file. You can customize your environment variables as desired by modifying your . env file.
If your goal is to use environment variables as liquid items {{ site.something }}
, you might be able to get this thing in your Gemfile
a go:
gem 'jekyll-environment-variables', group: :jekyll_plugins
And then you'll be able to use {{ site.env.HOME }}
and expect it be converted to something like /home/ubuntu
in the output HTML.
Disclosure: I am the owner of the gem and I've been using it personally since long ago.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With