Adds an example how to use frontmatter defaults with collections

This commit is contained in:
Jens Nazarenus 2014-06-01 21:53:21 +02:00
parent ae67940544
commit 460d9c1c44
1 changed files with 18 additions and 1 deletions

View File

@ -309,7 +309,8 @@ defaults:
layout: "default" layout: "default"
{% endhighlight %} {% endhighlight %}
Now, this will only set the layout for files where the type is `post`. The different types that are available to you are `page`, `post`, or `draft`. While `type` is optional, you must specify a value for `path` when creating a `scope/values` pair. Now, this will only set the layout for files where the type is `post`.
The different types that are available to you are `page`, `post`, `draft` or any collection in your site. While `type` is optional, you must specify a value for `path` when creating a `scope/values` pair.
As mentioned earlier, you can set multiple scope/values pairs for `defaults`. As mentioned earlier, you can set multiple scope/values pairs for `defaults`.
@ -333,6 +334,22 @@ defaults:
With these defaults, all posts would use the `my-site` layout. Any html files that exist in the `projects/` folder will use the `project` layout, if it exists. Those files will also have the `page.author` [liquid variable](../variables/) set to `Mr. Hyde` as well as have the category for the page set to `project`. With these defaults, all posts would use the `my-site` layout. Any html files that exist in the `projects/` folder will use the `project` layout, if it exists. Those files will also have the `page.author` [liquid variable](../variables/) set to `Mr. Hyde` as well as have the category for the page set to `project`.
{% highlight yaml %}
collections:
- my_collection:
output: true
defaults:
-
scope:
path: ""
type: "my_collection" # a collection in your site
values:
layout: "default"
{% endhighlight %}
In this example the `layout` is set to `default` inside the [collection](../collections) with the name `my_collection`.
### Precedence ### Precedence
Jekyll will apply all of the configuration settings you specify in the `defaults` section of your `_config.yml` file. However, you can choose to override settings from other scope/values pair by specifying a more specific path for the scope. Jekyll will apply all of the configuration settings you specify in the `defaults` section of your `_config.yml` file. However, you can choose to override settings from other scope/values pair by specifying a more specific path for the scope.