Learning YAML Step by Step
- The YAML colon-space rule: key: value
- The four basic data types: string, number, boolean, null
- How to spot and fix the most common beginner mistakes
Don’t Worry, YAML is Easy
In this lesson, we’ll learn how to write YAML files. Think of YAML like writing a very organized shopping list or recipe. There are just a few simple rules to follow.
The Most Important Rule: Spaces Matter
The most important thing to remember about YAML is that spaces matter. Just like when you write an outline for an essay, you use indentation to show which items belong together.
Important: Always use the space bar, never use the Tab key!
Rule 1: Writing Simple Information (Key-Value Pairs)
The simplest way to store information in YAML is like this:
This is like saying:
- The name is “My Semiconductor Design”
- The speed is 100
- The designer is “John Smith”
Remember: Always put a space after the colon (:)
Watch how each pair is built, piece by piece — the key (label), the colon, the mandatory space, and the value:
Interactive: Anatomy of a YAML Pair
Watch three lines being built — each part is color-coded and explained
The YAML will build up on the left, piece by piece. Each colored part is explained here.
Rule 2: Adding Comments (Notes to Yourself)
You can add comments (notes) to your YAML file using the # symbol. Comments are ignored by computers but help humans understand the file:
Comments are like sticky notes — they help you remember what each setting does.
Rule 3: Different Types of Information
YAML can handle different types of information. Click the tabs below to explore each type:
Text (Strings)
Numbers
True or False (Booleans)
Your First Complete YAML File
Let’s put it all together and create a simple semiconductor design configuration. Watch it being built line by line — click any line to read what it does:
Interactive: Building a YAML File Line by Line
Click Next to add lines — click any line to read what it does in plain English
Click Next to start building the file. Each line is explained here.
Here is the complete file with all sections. Notice the dots showing indentation — 2 dots for items inside a group:
Understanding Indentation (The Space Rule)
Look at this example carefully — count the dots at the start of each line:
Think of it like this family tree:
- chip_design (grandparent — 0 spaces)
- name (child — 2 spaces)
- speed (child — 2 spaces)
- details (child — 2 spaces)
- size (grandchild — 4 spaces)
- power (grandchild — 4 spaces)
Common Beginner Mistakes (And How to Avoid Them)
Click through each mistake — see the error highlighted in red on the left, then click “Show Fix” to see the corrected version slide in on the right:
Interactive: Common Beginner Mistakes
See each mistake, spot the error, then click "Show Fix" to see the correction
Key takeaways
Congratulations! You now know the basic rules of YAML:
- Key-value pairs: Use
name: valueformat - Comments: Use
#for notes - Indentation: Use spaces (not tabs) to show relationships
- Lists: Use
-to make bullet points - Data types: Text, numbers, and true/false values
These simple rules are all you need to start writing YAML files. In the next lesson, we’ll learn how to organize more complex information using these same basic rules.