Retrieving Custom FrontMatter? #35
-
Hi, If I want to add a custom frontmatter key/value pair, like The document, https://statiq.dev/web/content-and-data/metadata/front-matter, doesn't say how to access those values either. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Great question, I'll add some additional detail to the docs! The way front matter works is that it gets stored in the document as a key/value pair. The document is very much like a In a Razor page that might look like |
Beta Was this translation helpful? Give feedback.
Great question, I'll add some additional detail to the docs! The way front matter works is that it gets stored in the document as a key/value pair. The document is very much like a
Dictionary<string,object>
with some extra super-powers like handy type conversion. To put it another way, you use the name of the front matter as a string-based key anywhere you have anIDocument
.In a Razor page that might look like
Model["GetImageUrl"]
(since theModel
property is set to the current document in Razor, though you could also useDocument
instead). We generally don't access document metadata using the raw indexer though, instead it's often easier to access via one of the specialGet...
type conv…