jekylljekyll-extensions

Exclude files based on the JEKYLL_ENV?


In a Jekyll site one excludes files like this:

exclude:
    - "*.json"
    - "Gemfile*"
    - "*.txt"
    - vendor
    - README.md
    - somefile.html

So to create the production build I run: $ JEKYLL_ENV=production bundle exec jekyll build

How can I exclude the somefile.html file only when I run the production ENV?


Solution

  • Perhaps you could try using a specific config file for production and one for development. In the production you could exclude the files using exclude as described here.

    Then run:

    jekyll build --trace --config _config.yml,_config_dev.yml

    or

    jekyll build --trace --config _config.yml,_config_prod.yml

    In the _config.yml you'd set generic settings, and in the config with the environment suffix you'd set a environment specific configuration.


    The trace flag is optional, it will help setting it up since it will show occuring errors.

    optional: -t, --trace Show the full backtrace when an error occurs