There are several ways to add metadata to both content and data files and metadata is merged together from multiple sources to determine the complete set of metadata for a given document. This data cascade (credit to 11ty for the excellent term) applies metadata from the lowest priority source to the highest. A document will contain metadata from all the sources, but if a higher priority metadata source contains the same key as a lower priority one, the value from the higher priority source will take precedence.
Note that global settings cascade to documents. This can be helpful because it means you can define metadata that's intended for use by documents as a global setting and it will cascade to every document as a default value.
Here are the default metadata sources from lowest priority to highest. Think of metadata being applied (or cascaded) from the top of this list to the bottom, with duplicate keys overwriting existing values along the way.
- Environment variables.
- Configuration files.
- Default Statiq Framework settings.
- Default Statiq Web settings.
- Settings you define via the Bootstrapper.
- Directory metadata (closer to the file have higher priority).
- Sidecar files.
- Front matter.
- Parsed data content (if a data file).
Directory metadata allows you to specify metadata that applies to all files in a given directory (and optionally all subdirectories).
Sidecar files let you define metadata in a separate file.
Front matter is a common concept in static generators that lets you define metadata for a file in a file header.