skip to content
blog.metters.dev
Table of Contents

TLDR

  1. Convert the markdown file (*.md) into an extended markdown file (*.mdx)
  2. Access the frontmatter value via the following syntax {frontmatter.<name of the property>}

A bit more details

Let’s say I want to access the title in the body of my blog post. The title is defined in the frontmatter of the markdown file. The frontmatter of this blog post looks like this

---
title: "Access frontmatter values in Astro markdown"
description: ""
publishDate: "2025.06.01"
tags: ["til", "markdown", "astro", "how-to", "πŸ‡¬πŸ‡§"]
---

Example

Accessing the 'title' property
{frontmatter.title}

will be compiled into

Access frontmatter values in Astro markdown

Resources

  • Of course, the official documentation also explains this, and I only found it after I wrote this post!
  • This ultra short post was the original source, but did not mention that I need to convert the .md file into a .mdx file
  • More about extended markdown