R Markdown has a simple website builder baked in (see the R Markdown book for a detailed description). An R Markdown website must have at least have an index.Rmd file and a _site.yml file (which can be empty). Including YAML in _site.yml will apply it to all R Markdown files for the website, e.g. setting the output format here will tell R Markdown to use that format across the website. R Markdown websites also support navbars, which you can specify with YAML (see yml_navbar(), as well as ?rmarkdown::render_site and ?rmarkdown::html_document). Pass navbar_page() to the left or right field to set up page tabs and use navbar_separator() to include a separators. In addition to writing YAML with yml_*() functions, use_site_yml() will take the a yml object and write it to a _site.yml file for you.

yml_site_opts(
  .yml,
  name = yml_blank(),
  favicon = yml_blank(),
  output_dir = yml_blank(),
  include = yml_blank(),
  exclude = yml_blank(),
  new_session = yml_blank(),
  ...
)

yml_navbar(
  .yml,
  title = yml_blank(),
  type = yml_blank(),
  left = yml_blank(),
  right = yml_blank(),
  ...
)

navbar_page(
  text = yml_blank(),
  href = yml_blank(),
  icon = yml_blank(),
  menu = yml_blank(),
  ...
)

navbar_separator()

Arguments

.yml

a yml object created by yml(), as_yml(), or returned by a yml_*() function

name

The name of the website

favicon

Path to a file to use as the favicon

output_dir

Directory to copy site content into ("_site" is the default if none is specified)

include, exclude

Files to include or exclude from the copied into output_dir. You can use * to indicate a wildcard selection, e.g. "*.csv".

new_session

Logical. Should each website file be rendered in a new R session?

...

additional named R objects, such as characters or lists, to transform into YAML

title

The title of the website

type

The color scheme for the navigation bar: either "default" or "inverse".

left, right

the side of the navbar a navbar_page() should go (see example)

text

The link text

href

The link URL

icon

An icon to include

menu

drop-down menus specified by including another navbar_page()

Value

a yml object

Examples

yml_empty() %>%
  yml_site_opts(
    name = "my-website",
    output_dir =  "_site",
    include = "demo.R",
    exclude = c("docs.txt", "*.csv")
  ) %>%
  yml_navbar(
    title = "My Website",
    left = list(
      navbar_page("Home", href = "index.html"),
      navbar_page(navbar_separator(), href = "about.html")
    )
  ) %>%
  yml_output(html_document(toc = TRUE, highlight = "textmate"))
#> ---
#> name: my-website
#> output_dir: _site
#> include: demo.R
#> exclude:
#> - docs.txt
#> - '*.csv'
#> navbar:
#>   title: My Website
#>   left:
#>   - text: Home
#>     href: index.html
#>   - text: '---------'
#>     href: about.html
#> output:
#>   html_document:
#>     toc: true
#>     highlight: textmate
#> ---
#>