Urgent.News

What's breaking now, across thousands of outlets.

Tech

I Got Tired of Broken YAML Front Matter in Obsidian — So I Built a No-Upload Fixer

If you use Obsidian, Hugo, or Jekyll, you've probably seen this error: YAML front matter parsing error: ... It usually shows up right when you need the note most. And the worst part? The error message tells you something is wrong, but rarely where . The three mistakes I kept making After way too many broken notes, I noticed the same culprits: Tabs instead of spaces. YAML forbids tabs for…

Tired of encountering YAML front matter parsing errors in Obsidian, Hugo, or Jekyll? You're not alone. These errors often occur right when you need the note most, and they can be tricky to diagnose. After experiencing multiple instances of broken notes, the author discovered that the issues were typically due to three common mistakes: using tabs instead of spaces for indentation, forgetting to close the block with ---, and improperly formatting yes/no values or numbers.

The most frustrating aspect was that the error messages did little to pinpoint the exact location of the problem, which could make troubleshooting a frustrating and time-consuming experience. For instance, a single pasted tab could render an entire block invalid, and unquoted values like yes, no, or numbers could be silently converted, leading to unintended changes in your data.

To address this issue, the author created a no-upload YAML front matter validator that runs entirely in the browser. This tool only checks the --- block, ensuring that the Markdown body does not cause any false errors. Upon running the validator, it will show the exact line where the error occurred, along with a breakdown of the changes made. It adds a missing closing ---, trims trailing whitespace that could break parsing, and correctly formats yes/no values and numbers as strings, preserving their intended meaning.

For example, the validator would transform the following incorrect front matter into the correct format:

Before:

```yaml

title : My Note

tags : a, b

draft : yes

```

After:

```yaml

title: My Note

tags: - a - b

draft: yes

```

The validator also ensures that boolean values like "yes" are preserved as strings rather than being converted into booleans, which can be crucial for the note to render correctly. Additionally, it reports every change it made, line by line, so you can see exactly what adjustments were needed.

While there are other YAML fixers available, this no-upload fixer offers the unique benefit of not uploading your private notes to a server for validation, which is particularly important for sensitive information such as reading lists, daily journals, or work-in-progress notes. This tool can also be used to validate plain YAML files, such as those used in GitHub Actions or Docker Compose files, before committing changes, ensuring that your configuration files remain error-free.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Thursday 27 August →