Skip to contents

Extracts the YAML metadata block (between --- delimiters) from a .qmd or .md file. This is the primary way to programmatically inspect document metadata before generation or validation. Returns NULL when frontmatter is absent, allowing callers to distinguish "no metadata" from "empty metadata."

Usage

parse_quarto_yaml(path)

Arguments

path

Path to a .qmd or .md file. The file must exist; passing NULL or a nonexistent path raises an error because silent fallback would mask configuration problems in automated pipelines.

Value

A named list of frontmatter fields, or NULL if the file contains no valid ----delimited YAML block.

See also

Other extraction: parse_quarto_body()

Examples

path <- tempfile(fileext = ".qmd")
writeLines(c(
  "---",
  "title: Guide",
  "description: How to use the platform.",
  "---",
  "",
  "Content here."
), path)
fm <- parse_quarto_yaml(path)
fm$title
#> [1] "Guide"
fm$description
#> [1] "How to use the platform."