Skip to content

Retrieving Custom FrontMatter? #35

Answered by daveaglick
justinyoo asked this question in Q&A
Discussion options

You must be logged in to vote

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 an IDocument.

In a Razor page that might look like Model["GetImageUrl"] (since the Model property is set to the current document in Razor, though you could also use Document instead). We generally don't access document metadata using the raw indexer though, instead it's often easier to access via one of the special Get... type conv…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@justinyoo
Comment options

Answer selected by daveaglick
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #35 on December 17, 2020 02:28.