YAML is a lightweight data serialization format used in Obsidian to add metadata (often referred to as "front matter") to your notes. This metadata can then be used by plugins (like Dataview) for organizing, filtering, and querying your notes. Here’s a quick tutorial:
1. Understanding YAML Front Matter
What it is:
A block of key-value pairs enclosed at the top of your note between two lines of three dashes (---).
Standard format:
---
key: value
another_key: another_value
---
Everything between the opening and closing --- is interpreted as YAML metadata.
2. Creating YAML Front Matter
Placement:
Place the YAML block at the very beginning of your note.
Basic Example:
---
title: My Note Title
date: 2023-10-01
tags: [obsidian, notes, tutorial]
---
# Content starts here
This is the body of your note.
3. Common Uses and Keys
Standard Keys:
title: A custom title for the note.
date: Creation or publication date.
tags: An array of tags for categorization.
Custom Metadata:
You can define custom keys for project names, statuses, authors, etc.
---
project: Personal Wiki
status: Draft
---
Tags:
Tags can also be defined without YAML in the body using hashtags, but YAML tags can be easier to query.
4. Using YAML with Plugins
Dataview Plugin:
Use YAML metadata fields to create dynamic views and queries.
Example query to list notes with a specific tag:
TABLE title, date
FROM "Notes"
WHERE contains(tags, "tutorial")
Other Plugins:
Many community plugins read YAML for additional functionality like linking, task management, and more.
5. Tips and Best Practices
Syntax:
Ensure no indentation errors; YAML is whitespace-sensitive.
Always start and end with --- on separate lines.
Consistency:
Maintain consistent keys across your notes for smoother querying.
Validation:
If you run into issues, double-check your YAML syntax; online YAML linters can help verify your format.
By leveraging YAML in Obsidian, you can turn your notes into structured data sources, making it easier to organize, filter, and create custom dashboards with plugins like Dataview. Enjoy building a personal knowledge base!