Build a websiteSource:
Build the site through Hugo, and optionally (re)build R Markdown files.
Whether to run
hugo_build()after R Markdown files are compiled.
Whether to (re)build R Markdown files. By default, they are not built. See ‘Details’ for how
build_rmd = TRUEworks. Alternatively, it can take a vector of file paths, which means these files are to be (re)built. Or you can provide a function that takes a vector of paths of all R Markdown files under the
content/directory, and returns a vector of paths of files to be built, e.g.,
build_rmd = blogdown::filter_timestamp. A few aliases are currently provided for such functions:
build_rmd = 'newfile'is equivalent to
build_rmd = blogdown::filter_newfile,
build_rmd = 'timestamp'is equivalent to
build_rmd = blogdown::filter_timestamp, and
build_rmd = 'md5sum'is equivalent to
build_rmd = blogdown::filter_md5sum.
Other arguments to be passed to
You can use
serve_site() to preview your website locally, and
build_site() to build the site for publishing. However, if you use a
web publishing service like Netlify, you do not need to build the site
locally, but can build it on the cloud. See Section 1.7 of the blogdown
book for more information:
For R Markdown posts, there are a few possible rendering methods:
custom. The method can be set in
the global option
blogdown.method (usually in the
.Rprofile file), e.g.,
.Rmd posts are rendered to
rmarkdown::render(), which means Markdown is
processed through Pandoc. For the
.md, which will typically be rendered to HTML later by the
site generator such as Hugo.
For all rendering methods, a custom R script
R/build.R will be
executed if you have provided it under the root directory of the website
(e.g. you can compile Rmd to Markdown through
knitr::knit() and build the site via
custom method means it is entirely up
to this R script how a website is rendered. The script is executed via
Rscript "R/build.R", which means it is executed in a
separate R session. The value of the argument
local is passed to the
command line (you can retrieve the command-line arguments via
commandArgs(TRUE)). For other rendering methods, the R script
R/build2.R (if exists) will be executed after Hugo has built the site.
This can be useful if you want to post-process the site.
build_rmd = TRUE, all Rmd files will be (re)built. You can set
the global option
blogdown.files_filter to a function to determine
which Rmd files to build when
build_rmd = TRUE. This function takes a
vector of Rmd file paths, and should return a subset of these paths to be
built. By default,
options(blogdown.files_filter = identity.
You can use
blogdown::filter_newfile, which means to build new
Rmd files that have not been built before, or
blogdown::filter_timestamp to build Rmd files if their time
stamps (modification time) are newer than their output files, or
blogdown::filter_md5sum, which is more robust in determining if
an Rmd file has been modified (hence needs to be rebuilt).