render_site(input = ".", output_format = "all", envir = parent.frame(),
quiet = FALSE, encoding = getOption("encoding"))clean_site(input = ".", preview = FALSE, quiet = FALSE,
encoding = getOption("encoding"))
site_generator(input = ".", output_format = NULL,
encoding = getOption("encoding"))
new.env
to guarantee an empty new
environment).TRUE
to suppress messages and other output.file
.render_site
returns the name of the site output file (relative to the input directory).
clean_site
returns the names of the generated files removed during cleaning.rmarkdown::default_site
render_site
ensures that dependencies (e.g. CSS, JavaScript, images, etc.) remain in external files. CSS/JavaScript libraries are copied to a "site_libs" sub-directory and plots/images are copied to "_files" sub-directories.name: my-website output_dir: _site include: ["demo.R"] exclude: ["docs.txt", "*.csv"] navbar: title: "My Website" left: - text: "Home" href: index.html - text: "About" href: about.html output: html_document: toc: true highlight: textmate
The name
field provides a suggested URL path for your website when it is published (by default this is just the name of the directory containing the site). The output_dir
indicates which directory to copy site content into ("_site" is the default if none is specified). Note that this can be "." to keep all content within the root website directory alongside the source code.
The include
and exclude
fields enable you to override the default behavior visa-vi what files are copied into the "_site" directory (wildcards can be used as in the above example).
The navbar
field can be used to define a navigation bar for websites based on the html_document
format.
Finally, the output
field enables you to specify output options that are common to all documents within the website (you can also still provide local options within each document that override any common options).
rmarkdown::default_site
) is described above. It is also possible to define a custom site generator that has alternate behavior. A site generator is an R function that is bound to by including it in the "site:" field of the "index.Rmd" or "index.md" file. For example:title: "My Book" output: bookdown::gitbook site: bookdown::bookdown_site
A site generation function should return a list with the following elements:
name
output_dir
{The directory where the website output is written to.
This path should be relative to the site directory (e.g. "." or "_site")}render
input_file
, output_format
,
envir
, quiet
, and encoding
arguments.}
clean
render_site
(these files are the ones which will be removed
by the clean_site
function.}render_site
function enables you to render a collection of markdown documents within a directory as a website. There are two requirements for a directory to be rendered as a website: