Learn R Programming

ymlthis: write YAML for R Markdown, bookdown, blogdown, and more

Status: Retired

ymlthis is now retired: only changes necessary to keep it on CRAN will be made. ymlthis was created when managing YAML in R Markdown was difficult. Quarto has since resolved these issues with autocomplete, validation, and helpful error messages for YAML. We recommend Quarto for new projects. Existing ymlthis code will continue to work, and the package will remain on CRAN.

ymlthis makes it easy to write YAML front matter for R Markdown and related documents. yml_*() functions write functions and use_*() functions let you write the resulting YAML to your clipboard or to .yml files related to your project.

Installation

You can install ymlthis from CRAN with:

install.packages("ymlthis")

Or you can install the development version of ymlthis from GitHub with:

# install.packages("remotes")
remotes::install_github("r-lib/ymlthis")

Example

yml() creates a basic yml object returns simple YAML with the author and date.

library(ymlthis)

yml()
#> ---
#> author: Malcolm Barrett
#> date: '`r format(Sys.Date())`'
#> ---

ymlthis supports many YAML arguments, with YAML-generating functions prefixed with yml_*():

yml() %>% 
  yml_author(c("Yihui Xie", "Hadley Wickham"), affiliation = "RStudio") %>% 
  yml_date(lubridate::today()) %>% 
  yml_output(
    word_document(keep_md = TRUE), 
    bookdown::html_document2()
  ) %>% 
  yml_citations(bibliography = "references.bib", csl = "aje.csl")
#> ---
#> author:
#> - name: Yihui Xie
#>   affiliation: RStudio
#> - name: Hadley Wickham
#>   affiliation: RStudio
#> date: '2026-02-16'
#> output:
#>   word_document:
#>     keep_md: true
#>   bookdown::html_document2: default
#> bibliography: references.bib
#> csl: aje.csl
#> ---

Add-in

ymlthis also includes an add-in that will create YAML for you and put it in a file, such as an .Rmd file, or on your clipboard.

Copy Link

Version

Install

install.packages('ymlthis')

Monthly Downloads

1,165

Version

1.0.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Malcolm Barrett

Last Published

February 17th, 2026

Functions in ymlthis (1.0.0)

yml_citations

Set citation-related YAML options
yml_latex_opts

Set LaTeX YAML options for PDF output
yml_bookdown_opts

Set Top-level YAML options for bookdown
yml_blank

Return a blank object to be discarded from YAML
yml_clean

Remove intermediate rendering files
yml_author

Set Top-level R Markdown YAML Fields
yml_blogdown_opts

Set Top-level YAML options for blogdown
yml_code

Take code and write it as valid YAML
yml_distill_opts

Set Top-level YAML options for distill
yml_handlers

Set handlers to process the way YAML is printed
yml_pagedown_opts

Top-level YAML options for pagedown
yml_rsconnect_email

Set YAML for Scheduled Emails in RStudio Connect
yml_resource_files

Add external resource files to R Markdown document
yml_load

Load YAML from string
yml_output

Capture, validate, and write output YAML
yml_rticles_opts

Set YAML related to rticles output formats
yml_params

Parameterize an R Markdown report using Shiny components
yml_replace

Replace, pluck, or discard top-level YAML fields
yml_pkgdown

Set Top-level YAML options for pkgdown
yml_reference

Write references as YAML fields
yml_verbatim

Write YAML field or content verbatim
yml_toc

Specify Table of Contents options
yml_vignette

Set up a package vignette
yml_site_opts

Add site options for _site.yml and navbars for R Markdown websites
yml_runtime

Activate Shiny in R Markdown
has_field

Check if field exists in YAML
gitbook_config

Configure bookdown::gitbook() output
as_yml

Convert to yml object
is_yml

Is object a yml object?
asis_yaml_output

Export yml object as a YAML knitr code chunk
blogdown_template

Create YAML based on blogdown theme archetypes
code_chunk

Write code chunks programmatically
includes2

Include content within output
bib2yml

Convert bib files to YAML
draw_yml_tree

Draw an tree of YAML hierarchy
read_json

Read and write to JSON and TOML
pkgdown_template

Generate a full YAML template for your pkgdown site
use_yml_defaults

Set up default YAML
%>%

Pipe operator
use_yml_file

Write YAML to file
yml

Create a new yml object
pandoc_template_types

Use pandoc templates and custom highlight themes
use_yml

Copy YAML code to your clipboard or write to a new R Markdown file
last_yml

Return the most recently printed YAML
pagedown_business_card_template

Generate a full YAML template for your pagedown business card