YAML includes Atoms, Maps, and Lists[1]

HIDDEN[1]

YAML is a data-serialization language that can include Atoms, Maps and Lists.[2]

An atom, which is also known as a scalar, is the elementary particle of a YAML serialization. An atom is usually either…

A map is a key/value pair. Here are a couple example YAML maps:

key1: value1
key2: value2

Here is an example of a YAML list:

- item1
- item2
- item3

These data structures can have names, also known as keys. For example:

name1:
  key1: value1
  key2: value2

name2:
  - item1
  - item2
  - item3

Note that name1 is a key whose value is a couple maps and name2 is a key whose value is a three-item list. Naming a collection is a way to turn it into a block or object (with sub-objects) that can be referenced.

In general, you do not need to use quotation marks around YAML strings. Quoting a string is required if it…

A list is also known as an array (and sometimes a slice). A named map, for example name1, is also known as an associative array, a dictionary, a dict, a hash table, a hash, a map, an object, or a table.

‼︎

In YAML:

  • Spacing matters.

  • Tabs are not allowed.[3]

  • Lines that begin with a hash (#) are comments and are ignored.

YAML references

Notes


1. An earlier version of this article was in Infinite Ink’s TGIH: Themeless & Gitless Introduction to Hugo in the section called “7.2 About YAML.”
2. I like to think that the AML part of YAML stands for Atoms, Maps, and Lists, but this is not what the YAML acronym really stands for.
3. Tabs are allowed in some parts of a YAML serialization, but it is safest not to use them.

Discussion and reactions

Please post a comment or reaction so I know that someone other than me has read this! Thanks to Utterances and GitHub, the possible reactions are 👍️ 👎️ 😂️ 🎉️ 😕️ ❤️ 🚀️ and 👀️.