TL;DR: When using two config files, any collection only defined in the first config file does not get created appropriately. How can I tell Jekyll to merge the lists of collections and front matter defaults in both config files, rather than overwrite them?
Background
I have a blog based on the Minimal Mistakes theme. It has several collections.
I have several normal ones (_posts, _pages, and _about). These ones should show up on the public website hosted by Cloudflare pages, and I want to see them when I’m hosing them locally with jekyll serve.
I have two collections that I only want to show up when I’m working and hosting locally - _docs and _examples. These host the Minimal Mistakes documentation and example posts, so I can access them locally and update them as I add new liquid snippets specific to my site. I do not want these to show up on the public site.
Because I need local configuration, I’ve done the standard thing, and I’m using two config files: _config.yml and _config_dev.yml.
To serve my site, I run bundle exec jekyll serve --config _config.yml,_config_dev.yml -h 10.0.0.165
_config.yml has the collection definition and front matter defaults for _posts, _pages, and_about. _config_dev.yml has the collection definition and front matter defaults for _docs and _examples. I’ve included those sections of the files below.
\_config.yml collections and front matter definitions
### Collections
collections:
# Posts has defaults. Posts is the blog.
# Pages has defaults
about:
output: true
permalink: /:collection/:path/
### Post Front Matter defaults
words_per_minute : 200
defaults:
# _posts
- scope:
path: ""
type: posts
values:
layout: single
author_profile: true
read_time: true
comments: true
share: true
related: true
show_date: true
# _pages
- scope:
path: "_pages"
type: pages
values:
layout: single
author_profile: true
# _about
- scope:
path: "_about"
type: about
values:
layout: single
author_profile: false
\_config_dev.yml collections and front matter definitions
### Additional Local Collections
collections:
docs: #[[Local Config]]
output: true
permalink: /:collection/:path/
examples: #[[Local Config]]
output: true
permalink: /:collection/:path/
### Local Config Post Front Matter defaults https://mmistakes.github.io/minimal-mistakes/docs/configuration/#front-matter-defaults
defaults:
# _docs
- scope: #[[Local Config]]
path: "_docs"
type: docs
values:
layout: single
# _examples
- scope: #[[Local Config]]
path: "_examples"
type: examples
values:
layout: single
Expected Behavior
When I serve my site locally, with bundle exec jekyll serve --config _config.yml,_config_dev.yml -h 10.0.0.165 Jekyll reads the _config.yml and adds the elements in collections and front matter defaults to an internal database.
Then it reads the _config_dev.yml file, and sees that the collections and defaults trees have different elements. It adds the new elements to its internal database. If any elements conflict, it replaces those values with the values from _config_dev.yml.
The Symptom(s)
When I serve my site locally, pages in the _about folder, the _posts folder, and the _pages folder render without any CSS styling.
Adding a layout to the front matter manually improves the appearance, but it does not match what appears on the public site.
Copying the collections and defaults sections from _config.yml to _config_dev.yml fixes the layout entirely.
My Hypothesis
When using both _config.yml and _config_dev.yml, Jekyll does not add the elements of the collections and defaults trees to an internal database, but rather sees that the trees are different between the two files, and overwrites the entire tree.
The Question
How can I do what I want to do?
How can I prevent some collections from appearing on the public-facing website, while still letting them appear when I serve the site locally?
Am I going to be stuck duplicating the collections and defaults sections, and being careful that any changes I make to the public collections’ configurations get propagated to both the _config.yml and _config_dev.yml files?
Or is there something clever I don’t know about that will let me automatically tell Jekyll “hey, I want you to merge these two lists, not replace them”
Do I need to use some method other than _config_dev.yml?
Thanks in advance!