DocsGetting StartedMDXFrontmatter

Frontmatter

Learn how to use frontmatter in MDX files.

The frontmatter is an important part of an MDX file. It is used to define information about the content of the file, such as title, description, author, publication date, etc.

The metadata header is defined at the beginning of the file, between --- (three hyphens) at the beginning and end.

Format

The metadata header is defined in key-value format, where the key is the name of the metadata and the value is the content of the metadata.

Example:

---
title: Document title
description: Document description
---

Depending on the type of document (documentation, blog post, etc.), different metadata can be used.

Metadata for documentation

  • title
  • description
  • links
    • source
    • docs
    • blog
    • api

Example:

---
title: Document title
description: Document description
links:
  source: https://google.com
  docs: /docs
  blog: /blog
  api: https://google.com
---

Metadata for blog posts

  • title
  • excerpt
  • date
  • author_id
  • og_image
  • tags
  • links
    • source
    • docs
    • blog
    • api

Example:

---
title: Post title
date: 2024-08-07 22:33:00
excerpt: Post excerpt
author_id: daltonmenezes
og_image: introducing-blogs-og.jpg
links:
  source: https://google.com
  docs: /docs
  blog: /blog
  api: https://google.com
tags: [next.js, open-graph, blog]
---