Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a YAML front matter standard / validator?

I would like to use YAML front matter as a metadata holder for a general purpose data manager, e.g.:

---
layout: "user"
title: "Mario Brega"
slug: "mario-brega"
skills:
  - fire
  - water
  - leaf
---

# Here I will be using Markdown

yes I will, _I swear_

It is used by many static generators as:

  • docpad.js;
  • Jekyll;
  • Middleman

Question: is there a standard for that? Some tools that I can easily validate against, that for instance agree that all string values should be wrapped in quotes, that booleans should not, and so on.

Mapping the YAML front matter to a JSON schema would be a big plus.

like image 891
moonwave99 Avatar asked Jan 08 '15 11:01

moonwave99


People also ask

Where is the Yaml front matter?

YAML frontmatters can be defined at the beginning of a file, by starting on the first line with three dashes ( --- ) and ending the frontmatter either with three dashes or three dots (the former variant is more common). They contain valid YAML and can be used to define arbitrary variables.

What is front matter markdown?

Frontmatter is a way to identify metadata in Markdown files. Metadata can literally be anything you want it to be, but often it's used for data elements your page needs and you don't want to show directly. Some examples of common metadata are: Title of the post. Description for SEO purposes.


1 Answers

The closest thing to a standard would be Jekyll's Front Matter description. Everything else seems to follow that. If Jekyll didn't invent Yaml Front Matter, they were one of the first notable projects to feature it.

The YAML Lint linter has been able to verify the YAML components of every file I've thrown at it. According to the YAML spec, three-hyphens --- delimits documents; a single YAML file can contain many YAML documents. The Markdown content after the hyphen is simply dropped by the linter.

YAML is very loose and forgiving (mostly). Quoting all your strings won't hurt, but you probably don't need to bother.

The desire for some sort of baseline Markdown standard is what led to the CommonMark project.

So, while there is no formal specification, a pattern of best practices has emerged. Sticking to that pattern results in some surprisingly portable and versatile data files.

like image 114
joemaller Avatar answered Sep 26 '22 07:09

joemaller