#Can't read data (frontmatter) using Astro content collections

6 messages · Page 1 of 1 (latest)

raw hill
#

The following is the frontmatter used throughout my content collection

---
topic = 1
chapter = 0
title = Measurements & uncertainties
---

However entry.data gives me "topic = 1 chapter = 0 title = Measurements & uncertainties", so entry.data.topic for example is null.

sterile garnet
#

Hey! I think it's your usage of = instead of :, which isn't valid YAML. Try this:

---
topic: 1
chapter: 0
title: Measurements & uncerctainties
---
raw hill
#

Oh my goodness, my eyes have failed me

candid lance
#

Also, it's a good idea to wrap things like the title in a string so that special characters don't accidentally make YAML think they're control characters.

#

For example, there are several words that YAML will interpret as booleans; "yes", "no", "on", "off", "true", "false", etc. Unless they're wrapped in quotes.

#

or if your title is a number, like the game 1942 for NES. If you don't wrap it in quotes, it will be interpreted as an integer.