Skip to content

Instantly share code, notes, and snippets.

@cameronmcefee
Created June 19, 2018 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cameronmcefee/b587a31cc9abf675b5605b89950a26ec to your computer and use it in GitHub Desktop.
Save cameronmcefee/b587a31cc9abf675b5605b89950a26ec to your computer and use it in GitHub Desktop.
A Jekyll plugin to load all environment variables that start with "JEKYLL_" into the Jekyll config
module Jekyll
class EnvironmentVariablesGenerator < Generator
# Pass any environment variables that start with JEKYLL_ on to Jekyll, where
# they can be access on the `site` object, like {{ site.JEKYLL_MY_VAR }}
def generate(site)
keys = ENV.keys.select { |i| i[/^JEKYLL_/] }
keys.each { |k| site.config[k] = ENV[k] }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment