Accept multiple configuration files #703

Closed
parkr opened this Issue Dec 25, 2012 · 5 comments

Projects

None yet

5 participants

@parkr
Member
parkr commented Dec 25, 2012

It'd be cool if there were some way to cascade multiple config files.

jekyll -c _config.yml _site.yml _github.yml

It would gobble everything after the -c but before the next switch.

Other comments on this in #692.

@tombell
tombell commented Dec 25, 2012

What's the appeal of this? I don't see why someone would spread configuration variables over multiple files.

@parkr
Member
parkr commented Dec 26, 2012

I'm happy to explain.

If I have default configurations in a couple files and personal configurations in another, this is the easiest way to merge them together and have one big set of configs available to site. Or maybe I prefer to keep my jekyll-specific configurations in one file and my site customizations (variables for use in liquid) in another. I could do jekyll -c jekyll.yml site.yml and have all the variables available to my templates, while still allowinf for the logical separation of the disparate configurations.

@agarie
agarie commented Dec 26, 2012

We could have "standard configurations", too. A theme could have its own config file and the user would be able to overwrite it in another one, without alteration to the theme's files.

@xenji
xenji commented Dec 31, 2012

I'm close to having a pull request ready. With glob includes and circular reference detection ... The tests for the classic configuration method still work, but there are some of my new tests still failing.

@parkr parkr closed this Mar 16, 2013
@voidfiles

Hi, long time listener, first time caller. I am currently working on a project that could really use multiple _config.yml files. I found this patch which is perfect, and decided to see if I updated the code and got it to pass the tests if it could be reconsidered.

I have made some minor changes to @xenji. He should get most of the credit.

@voidfiles voidfiles added a commit to voidfiles/jekyll that referenced this issue Apr 1, 2013
@voidfiles voidfiles Added config includes to solve #514 and #703
This is origonaly form this checkin.
xenji/jekyll@2961201

I have only tried to cherry pick it on top of the current source
tree
including the corresponding tests and fixtures.

You can now use a YAML list to add configuration files to be included
in the order of the list.

The syntax supports globs (to be used with `Dir[pattern]`), relative
paths to the config value of `source` and absolute paths.

Using this sample config:
```
additional_configs:
  - additional_configs/_config_a.yml
  - additional_configs/_config_b.yml
```
or the glob version:
```
additional_configs:
  - additional_configs/_config_*.yml
```
the new deep merge order is in both cases:
`Jekyll::DEFAULTS < _config < _config_a < _config_b`

I've added additional tests for three use cases:
* Having one inclusion
* Having a glob inclusion
* Having one inclusion with override in the main config

Conflicts:
	lib/jekyll/configuration.rb
	test/test_configuration.rb
e38e4b2
@voidfiles voidfiles added a commit to voidfiles/jekyll that referenced this issue Apr 10, 2013
@voidfiles voidfiles Accept multiple config files from command line
Parse config as if it can contain multiple references to config files.
This allows you to pass in multiple config files from the command line

Helps with issues #514 and #703
df1efef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment