...

/

Extracting YAML Frontmatter from Documents

Extracting YAML Frontmatter from Documents

Learn how to extract YAML frontmatter using different techniques.

When working with text formats, such as Markdown, it is widespread to come across the concept of YAML frontmatter. These frontmatter documents are a section of the otherwise standard Markdown or similar file with a YAML document embedded at the top of the file. This usually looks like the example found in the code snippet below:

Press + to interact
---
title: An Unassuming Title
---
This is the content.
---
This is more content.

From above, we can note that the YAML frontmatter is typically delimited from the rest of the document by having a line containing --- that surrounds the frontmatter. Splitting an input string into its YAML frontmatter and content is relatively trivial. However, it is also simple enough that we can use it to discuss some other exciting string-splitting techniques.

Extracting YAML

...