Browse all lessons

Lesson 08 of 12 · 1:29 video · practice includedNot yet complete

Give a document useful metadata.

Combine YAML and Markdown, compare literal and folded text, and check a small schema.

WATCH THE LESSON1:29 · narrated walkthrough
Read the descriptive transcript

Follow the complete narration and the changes shown in the video. Each example can be copied.

1. Front matter is a host convention.

The two lines of three dashes enclose YAML metadata. The Markdown document follows them. Front matter is a convention used by tools, not a feature every Markdown reader must understand.

Source shown

---
title: Garden guide
draft: "false"
summary: |
  First line.
  Second line.
---
# Garden guide

On screen

The cursor highlights the relevant source or result while the narration explains it.

2. 01 / Correct the field type

Draft currently contains the string false. For our example contract, it must be a boolean. Replace the quoted value with false without quotes. Watch the parsed type change.

Source shown

---
title: Garden guide
draft: false
summary: |
  First line.
  Second line.
---
# Garden guide

On screen

YAML validity and the application schema are separate checks.

3. 02 / Preserve line breaks with a vertical bar

Summary uses a vertical bar. Its two indented lines become one string with line breaks. In the JSON display, backslash n represents each newline.

Source shown

---
title: Garden guide
draft: false
summary: |
  First line.
  Second line.
---
# Garden guide

On screen

Literal block: | keeps these line breaks.

4. 03 / Compare a folded block

Replace the vertical bar with a greater than sign. In this simple folded block, the line break between the two sentences becomes a space. The final newline remains.

Source shown

---
title: Garden guide
draft: false
summary: >
  First line.
  Second line.
---
# Garden guide

On screen

Folded block: > joins these two plain lines.

5. Keep the form that matches your meaning

Our summary needs separate lines, so restore the vertical bar. Neither version is universally better. Choose based on how the next tool should read the value.

Source shown

---
title: Garden guide
draft: false
summary: |
  First line.
  Second line.
---
# Garden guide

On screen

The source is edited character by character and its parsed result updates.

6. The body stays outside the metadata

The closing delimiter ends the YAML. The heading below is Markdown. Keep document prose in the body and use only metadata fields the receiving tool documents.

Source shown

---
title: Garden guide
draft: false
summary: |
  First line.
  Second line.
---
# Garden guide

On screen

The cursor highlights the relevant source or result while the narration explains it.

7. Your turn / Test both string styles

In the exercise, correct the draft type and add both a literal summary and a folded description. Compare the result before pressing Check structure. This checks our example contract, not every publishing system.

Source shown

---
title: Garden guide
draft: false
summary: |
  First line.
  Second line.
---
# Garden guide

On screen

The cursor highlights the relevant source or result while the narration explains it.

Put metadata before the document

Some tools read a YAML block at the beginning of a Markdown file as front matter. Astro is one example. Its delimiters and accepted fields are a tool convention, not a universal Markdown feature. Check the target tool before using them. Astro Markdown front matter, CommonMark specification.

---
title: Garden guide
draft: false
---

# Garden guide

A plan for a shared space.

In our exercise, the first block is metadata and the later heading is prose. A renderer that does not support front matter may show the delimiters or interpret them as Markdown. Metadata remains in the raw file even when a preview hides it.

Preserve lines or fold them

summary: |
  First line.
  Second line.
description: >
  A short
  garden guide.

The literal form | retains the line break between these ordinary lines. The folded form > turns that ordinary break into a space. Blank lines and more-indented lines have additional rules. This lesson uses the simple case; inspect the parser output rather than assuming every newline behaves identically. YAML block scalars.

For a postal address, preserving lines may be useful. For a description wrapped across source lines, folding may be useful. Neither choice improves factual accuracy.

Check syntax, then the receiving tool’s rules

Our fictional document contract requires title as text and draft as a boolean. The two descriptions are strings. The browser checks that contract and shows the parsed metadata separately from the Markdown body.

draft: 'false' # Valid YAML; wrong type for this exercise.

Remove the quotes to supply a boolean. Notice that the syntax could be valid before and after the change. Similarly, a correct draft field does not universally hide a page: only a tool that implements that behavior can do so.

Practice with a deliberate mistake

Repair the starter, add both block-scalar examples and retain a Markdown heading below the closing delimiter. Inspect the escaped \n characters in the parsed result. Then change draft back to a string and run the check. You should receive a field/type message rather than a syntax error.

For a real publishing system, check its schema and preview a disposable document before publishing. The exercise performs no publishing, file access or AI request.

Sources checked 17 September 2026. Host behavior can change; verify it against the linked documentation when using these examples.

YOUR TURN

Make the idea your own.

Make title a nonempty string and draft a boolean. Include a literal summary, a folded description and a Markdown title below the closing delimiter.

garden.mdText stays on this page

Parsed data and document

Parsed YAML (shown as JSON)

{
  "title": "Garden guide",
  "draft": "false"
}

Garden guide

Compare with one possible answer
---
title: Garden guide
draft: false
summary: |
  First line.
  Second line.
description: >
  A short
  garden guide.
---
# Garden guide

A plan for a shared space.

This is one approach. Your writing can differ while meeting the same structural goal.

TAKE IT WITH YOU

Valid YAML, valid metadata and accurate writing are three different checks.

Read the editor guide →
Agent-readable/learn/lessons/yaml-front-matter.md
Save .md