Default fields
Instead of defining fields each time you create a page, post, or document, you can set defaults in your _config.yml
theme file. In most cases, it’ll be handy to set at least the default layout.
The defaults
key in your _config.yml
file is a list of different defaults. Each list item has two objects: scope
and values
.
scope
is how you choose which collection and files you’re defining defaults on.values
is where you define your default fields as key/value pairs. Keys can be nested and their values are optional.
For example:
In this case, we’re:
- Setting the default
layout
andauthor
for all posts. - Setting the default
layout
for all pages. - Overriding the previous default
layout
for all pages in theprojects/
path, and setting a defaultcolors
List field with the valuesred
,green
,blue
. - Defining fields for
map.latitude
andmap.longitude
for all documents in thelocations
collection. Using blank values, these fields will show up to content editors but remain optional.
Note that type
can be posts
, pages
or any other collection name (e.g. people
).