Free preview · Beginner · 12 min read
YAML Foundations & Indentation
Learn the YAML mental model, core structure, indentation rules, key-value pairs, and comments.
YAML is a human-readable data format used heavily for configuration in DevOps, Cloud, CI/CD, Kubernetes, Docker Compose, Ansible, Helm, and monitoring systems.
Think in data, not decoration
YAML mainly represents:
- key-value pairs
- lists
- nested objects
- strings
- numbers
- booleans
- multiline values
YAML
name: bongoDev
course: DevOps and Cloud Engineering
duration: "4 months"
active: true
students: 200
The same data can be represented in JSON:
JSON
{
"name": "bongoDev",
"course": "DevOps and Cloud Engineering",
"duration": "4 months",
"active": true,
"students": 200
}
The most important rule: indentation
YAML uses indentation to express hierarchy. Use spaces, not tabs. For bongoDev examples, use 2 spaces per level.
YAML
server:
name: app-server
port: 8080
environment: production
Nested structure:
YAML
parent:
child:
grandchild: value
Key-value pairs
Basic syntax:
YAML
key: value
Always put a space after the colon:
YAML
# Correct
name: nginx
# Wrong
# name:nginx
Comments
Use # for comments.
YAML
# Application configuration
app:
name: student-api
port: 3000 # Used by the Node.js backend container
Good comments explain why a value exists rather than repeating the value.