Access frontmatter values in Astro markdown
/ 1 min read
Table of Contents
TLDR
- Convert the markdown file (
*.md
) into an extended markdown file (*.mdx
) - 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
{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