Front Matter

  • Metadata, data about our content files, in YAML, TOML, JSON markdown languages. Here you specify page attributes that you can later use in layouts.
a.yaml
---
title: "A"
---
a.toml
+++
title = 'A'
+++
  • Can create custom front matter variables. content/a.md:
+++
title = 'A'
date = 2024-10-10T20:37:08+07:00
draft = true
author = 'Mike'  # added
+++

Remember to do so for all .md files that will be using this variable (for content/dir1/b.md etc.) Humans have front matter: name, age, weight etc.

  • How you would use front matter variables in a layout:
<html>
  <head>
    <meta charset="UTF-8" />
    <title>{{ .Params.Title }}</title>
  </head>
  <body>
    <p>Written By : {{ .Params.Author }}</p>
    {{ .Content }}
  </body>
</html>