The front matter is the data that sits at the beginning of a file, before the actual content. It is used to store metadata, or information about the file itself. This might include the date the file was created, the author's name, or a description of the file's contents. The front matter is typically enclosed in a pair of triple-dashed lines, like so:
front matter
The front matter can be written in either YAML or JSON, and is often used in conjunction with Jekyll, a static site generator. When a file with front matter is processed by Jekyll, the front matter is parsed and made available to the template, which can then use it to populate the resulting page.
One use case for the front matter is storing information about blog posts. For example, a blog post might have a title, date, and author, which can be specified in the front matter:
layout: post
title: "My Great Blog Post"
date: 2020-01-01
author: Jane Doe
Another use case is storing information about images. For example, an image file might have a title, caption, and credit, which can be specified in the front matter:
title: "My Great Image"
caption: "A beautiful image of a sunset"
credit: "Photo by Jane Doe"
Yet another use case is storing information about a site's global configuration. For example, a site's _config.yml file might specify the site's title, URL, and author, like so:
title: My Great Site
url: https://example.com
author: Jane Doe
The front matter is a flexible tool that can be used for a variety of purposes. It is up to the developer to decide how best to make use of it.