A new Siteleaf is here, upgrade to v2 →

Siteleaf

Menu

Metadata

Metadata is pure key/value data attached to a site, page, post, or asset. It provides a way to interact with templates beyond the basic usage of injecting title or body copy. It could be a custom color value, location, an aside, anything.

Variable Description
meta Array of all metadata key/value pairs.
meta.KEY Get single metadata by key (ie. Color).

Available for each metadata:

Variable Description
key Name of metadata key (ie. Color).
value Value of metadata (ie. Red).

Count number of metadata fields:

{{meta | size}}

Get metadata for key Color:

{{meta.color}}

Get metadata for key My Color:

{{meta['My Color']}}

Loop through metadata:

<dl>
{% for data in meta %}
  <dt>{{data.key}}</dt> <dd>{{data.value}}</dd>
{% endfor %}
</dl>

Conditional for specific metadata value:

{% if meta.color.value == 'Red' %}
  <p>This color is red!</p>
{% endif %}

Get posts by metadata value:

{% assign sticky_posts = site.posts | where:"meta.sticky","yes" %}