This site is a work-in-progress. Some of the information is incomplete and may not work as described. See the homepage for details.

Table of Contents:

Using Different Config Files

When using multiple configuration files, you will run your build and serve commands using the --config flag like so:

bundle exec jekyll serve --config _config.yml,_config.local.yml

This will load _config.yml first and then _config.local.yml overwriting any key:value pairs in the main file.

$ bundle exec jekyll serve --config _config.yml,_config.local.yml
Configuration file: ~/jekyll-website/_config.yml
Configuration file: ~/jekyll-website/_config.local.yml
            Source: ~/jekyll-website
       Destination: ~/jekyll-website/_site
 Incremental build: enabled
      Generating...
                    done in 0.140 seconds.
 Auto-regeneration: enabled for '~/jekyll-website'
    Server address: http://127.0.0.1:4000
  Server running... press ctrl-c to stop.

_config.yml

Standard configuration for your site (used in production unless you create a specific production config file):

# Site Settings
url: https://example.com

# Jekyll Configuration
permalink: /:title/

# Sass/SCSS Settings
sass:
  style: compressed # http://sass-lang.com/documentation/file.SASS_REFERENCE.html#output_style

# API Settings
api_access_key: '627x90vnaw32ow93'
...

_config.local.yml

Configuration specific to local development:

# Site Settings
url: http://localhost:4000

# Jekyll Configuration
incremental: true

# Sass/SCSS Settings
sass:
  style: expanded

# API Settings
api_access_key: '389x90vnaw32ow93'

_config.staging.yml

Configuration specific to your staging environment:

url: http://staging.example.com
api_access_key: '154x90vnaw32ow93'

Using Environment Variables in Config File

# Environments
local:
  url: http://localhost:4000
  api_access_key: '389x90vnaw32ow93'
staging:
  url: https://staging.example.com
  api_access_key: '154x90vnaw32ow93'
production:
  url: https://example.com
  api_access_key: '627x90vnaw32ow93'

# Jekyll Configuration
permalink: /:title/
...

If you take this approach you will use jekyll.environment to call the values. For example accessing the api key above you would use:


{{ site[jekyll.environment].api_access_key }}