From a82b063d427b81f2f91dae0620c0b0a492efe8ca Mon Sep 17 00:00:00 2001 From: Tom Johnson Date: Tue, 22 Sep 2015 09:35:14 -0700 Subject: [PATCH 1/2] Added documentation for Jekyll environment variables Information about Jekyll environment variables was missing from the documentation. This seemed like a good place to include it. --- site/_docs/configuration.md | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/site/_docs/configuration.md b/site/_docs/configuration.md index 1c9b339f..4a5e0624 100644 --- a/site/_docs/configuration.md +++ b/site/_docs/configuration.md @@ -201,6 +201,14 @@ class="flag">flags (specified on the command-line) that control them.

--drafts

+ + +

Environment

+

Use a specific environment value in the build

+ + +

JEKYLL_ENV=production

+

Future

@@ -263,6 +271,8 @@ class="flag">flags (specified on the command-line) that control them. + + ### Serve Command Options In addition to the options below, the `serve` sub-command can accept any of the options @@ -339,6 +349,34 @@ before your site is served.

+## Specifying a Jekyll environment at build time + +In the build (or serve) arguments, you can specify a Jekyll environment and value. The build will then apply this value in any conditional statements in your content. + +For example, suppose you set this conditional statement in your code: + +```liquid + {% raw %} + {% if jekyll.environment == "production" %} + {% include disqus.html %} + {% endif %} + {% endraw %} +``` + +When you build your Jekyll site, the content inside the `if` statement won't be run unless you also specify a `production` environment in the build command, like this: + +```bash +JEKYLL_ENV=production jekyll build +``` + +Specifying an environment value allows you to make certain content available only within specific environments. + +The default value for `JEKYLL_ENV` is `development`. Therefore if you omit `JEKYLL_ENV` from the build arguments, the default value will be `JEKYLL_ENV=development`. Any content inside `{% raw %}{% if jekyll.environment == "development" %}{% raw %}` tags will automatically appear in the build. + +Your environment values can be anything you want (not just `development` or `production`). Some elements you might want to hide in development environments include Disqus comment forms or Google Analytics. Conversely, you might want to expose an "Edit me in Github" button in a development environment but not include it in production environments. + +By specifying the option in the build command, you avoid having to change values in your configuration files when moving from one environment to another. + ## Front Matter defaults Using [YAML Front Matter](../frontmatter/) is one way that you can specify configuration in the pages and posts for your site. Setting things like a default layout, or customizing the title, or specifying a more precise date/time for the post can all be added to your page or post front matter. From 38a561a14cd17f0cd28dcff1317ee3d7677f6ac2 Mon Sep 17 00:00:00 2001 From: Tom Johnson Date: Tue, 22 Sep 2015 14:28:32 -0700 Subject: [PATCH 2/2] Made small pull request fixes as noted by Parker --- site/_docs/configuration.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/site/_docs/configuration.md b/site/_docs/configuration.md index 4a5e0624..af4ce145 100644 --- a/site/_docs/configuration.md +++ b/site/_docs/configuration.md @@ -201,14 +201,15 @@ class="flag">flags (specified on the command-line) that control them.

--drafts

- +

Environment

-

Use a specific environment value in the build

+

Use a specific environment value in the build.

JEKYLL_ENV=production

+

Future

@@ -272,7 +273,6 @@ class="flag">flags (specified on the command-line) that control them. - ### Serve Command Options In addition to the options below, the `serve` sub-command can accept any of the options @@ -358,7 +358,7 @@ For example, suppose you set this conditional statement in your code: ```liquid {% raw %} {% if jekyll.environment == "production" %} - {% include disqus.html %} + {% include disqus.html %} {% endif %} {% endraw %} ``` @@ -373,7 +373,7 @@ Specifying an environment value allows you to make certain content available onl The default value for `JEKYLL_ENV` is `development`. Therefore if you omit `JEKYLL_ENV` from the build arguments, the default value will be `JEKYLL_ENV=development`. Any content inside `{% raw %}{% if jekyll.environment == "development" %}{% raw %}` tags will automatically appear in the build. -Your environment values can be anything you want (not just `development` or `production`). Some elements you might want to hide in development environments include Disqus comment forms or Google Analytics. Conversely, you might want to expose an "Edit me in Github" button in a development environment but not include it in production environments. +Your environment values can be anything you want (not just `development` or `production`). Some elements you might want to hide in development environments include Disqus comment forms or Google Analytics. Conversely, you might want to expose an "Edit me in GitHub" button in a development environment but not include it in production environments. By specifying the option in the build command, you avoid having to change values in your configuration files when moving from one environment to another.