Sashmark / Blog

YAML front matter errors: find the bad line

Bobby Huang ·

To investigate front matter errors, check the opening and closing dash lines first. Then parse the header on its own and check the line named in the error. Then look for colons inside values, indentation tabs, uneven list items and unquoted special characters.

Key takeaways

  • Check the two dash lines first. Most tools want the opening one on line 1 and a closing one after the last field.
  • A colon followed by a space inside a value breaks the line. Quote the value.
  • A space followed by a hash sign starts a comment and silently cuts the value short.
  • Tabs are not allowed for indentation, and list items must line up with each other.
  • Some values parse without an error but change type, such as yes, no, dates and ids with leading zeros.

For a front matter error, start by checking the opening and closing dash lines, then parsing the header alone and reading the reported line. AI coding agents write YAML headers on a lot of Markdown files: handoffs, plans, receipts. Most of the time they parse. When one does not, your build fails, your Markdown viewer shows raw text, or a script reads the wrong status.

This page lists the errors that cause most broken headers, with a broken example and a fixed one for each. For the basics of how front matter works, start with the YAML front matter guide. If the term is new, what is front matter in Markdown has a one-page definition.

How to find the bad line

  1. Check line 1. For broad compatibility, the file starts with ---, with nothing above it, not even a blank line. Check your tool's rules: Pandoc, for one, also accepts a metadata block later in the file.

  2. Check the closing line. Close the block with a second --- on its own line after the last field. Pandoc also accepts ... here, but --- works in more places.

  3. Parse the block on its own. If you have Python and the PyYAML package, this prints the parsed header or an error with a line number:

    python3 -c "import sys, yaml; print(yaml.safe_load(open(sys.argv[1]).read().split('---', 2)[1]))" HANDOFF.md
    

    The line numbers in the error match the file's own line numbers. This one-liner assumes the file starts with --- and that no value contains ---. PyYAML follows YAML 1.1, so it also shows you which values turn into booleans or dates.

  4. Go to the line in the error, then look one line up. YAML often notices a problem one line after it starts.

To skip the one-liner, the free YAML front matter checker reads the header in your browser and names each of the errors on this page with its line number, and the file stays on your computer.

Error 1: a colon inside a value

title: Fix: login loop

A colon followed by a space tells YAML a new key starts. Here that happens in the middle of a value, so the line fails. Quote the whole value:

title: "Fix: login loop"

A colon with no space after it is fine. url: https://example.com/docs parses as one string.

Error 2: a hash sign that cuts the value short

next: review PR #42

This one parses with no error, which makes it worse. A space followed by # starts a comment, so the value is just review PR. Quote it:

next: "review PR #42"

Error 3: a value that starts with a special character

owner: @jane-doe
title: [Draft] Migration plan

Some characters mean something at the start of a value. [ and { start a list or a map. * and & mark aliases and anchors. @ and the backtick are reserved. Quote any value that starts with one of them:

owner: "@jane-doe"
title: "[Draft] Migration plan"

Error 4: tabs used for indentation

The YAML spec does not allow tabs for indentation. A tab before a list item or a nested key often looks fine in an editor and still fails. Replace tabs with spaces. Two spaces per level is the common choice.

Error 5: list items that do not line up

tags:
  - ui
   - settings

Every item in one list needs the same indent. This one may not even raise an error. The extra space can turn the second line into part of the first item, so you get one tag, ui - settings, instead of two. Line them up:

tags:
  - ui
  - settings

For indented fields within fields, read the nested-key examples.

Error 6: yes, no, on and off

approved: no
country: NO

Under YAML 1.1, unquoted yes, no, on and off are booleans, in any of their common capitalizations. Under YAML 1.2, only true and false are. A YAML 1.1 parser reads both lines above as false. Use true or false for real booleans, and quote text that happens to match:

approved: false
country: "NO"

Error 7: dates and numbers that change type

date: 2026-10-06
version: 1.10
ticket: 0042

YAML 1.1 parsers may turn the date into a date object. 1.10 is a number, so it becomes 1.1. 0042 loses its leading zeros, and a YAML 1.1 parser may read it as an octal number. None of these raise an error. Quote values that must stay as typed:

date: "2026-10-06"
version: "1.10"
ticket: "0042"

Dates are the judgment call. Some tools want a real date to sort on. If a tool reads the header, check what it expects before you quote dates everywhere.

Error 8: backslashes and apostrophes inside quotes

path: "C:\Users\jane-doe\docs"
note: 'Jane Doe's draft'

Inside double quotes, a backslash starts an escape. \U starts an 8-digit Unicode escape and \j is not an escape at all, so the first line fails. A path like "C:\new" is worse: it parses with no error, because \n becomes a line break. Inside single quotes, an apostrophe ends the string, so the second line fails too. Swap the quote styles, or double the apostrophe:

path: 'C:\Users\jane-doe\docs'
note: "Jane Doe's draft"

Error 9: the same key twice

status: draft
owner: Jane Doe
status: published

Keys must be unique in YAML. Parsers handle a repeat differently. Some stop with an error. Others keep the last value without a warning. Agents that update a header by appending lines can cause this. Delete the stale line.

A habit that prevents most of this

Ask your agent to quote every string value in its headers and to use true and false for booleans. The header gets a little noisier and a lot more predictable. For each quoting case with its parsed result, see quoting strings, dates and lists in YAML front matter. If you review a lot of handoff files, a consistent header also makes the status and owner faster to find. To check what each common field means, see front matter fields you will often see.

Where Sashmark fits

Sashmark is a Markdown reader and editor for people whose AI agents write Markdown. It is in development; nothing has been released. There are no AI features in the app.

Questions

Should I use single or double quotes in YAML front matter?
Either works for most text. Use single quotes for values with backslashes, such as Windows paths, because single quotes do not treat a backslash as an escape. Use double quotes when the value contains an apostrophe, or double the apostrophe inside single quotes.
Why does my front matter parse but show the wrong value?
The value was read as a different type. Under YAML 1.1 rules, yes and no become booleans and unquoted dates can become date objects. A space and a hash sign also start a comment. Quote the value to keep it as text.
How do I check front matter without building the whole site?
Run the block through any YAML parser. The error message gives a line and column, which points you to the line to fix.

What Sashmark plans for v1: Features · Roadmap

View as Markdown