YAML includes Atoms, Maps, and Lists[1]

HIDDEN[1]

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

An atom 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…

 

‼︎

In YAML:

  • Spacing matters.

  • Tabs are not allowed.[3]

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

 

Terminology

An atom is also known as a scalar.

A list is also known as an array, a sequence, a slice, or a vector.

A named collection of maps, for example name1, is also known as an associative array, a dictionary, a dict, a hash table, a hash, a keyed list, a map, a named map, an object, a record, a struct, or a table.

References

Notes


1. An earlier version of this article was in Infinite Ink’s Hugo Tutorial: 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

All reactions and comments are welcome, including relevant links to your site and suggestions for improving this page. Thanks to GitHub and Utterances, the possible reactions are 👍️ 👎️ 😂️ 🎉️ 😕️ ❤️ 🚀️ and 👀️.