Reputation: 4768
I've been running into a problem when I make a change to a specific page, for example, adding a css theme to the YAML
document.
When I do this, I have to re-knit every .rmd
file so that it can produce a new html document with the css theme included. Is there any way for me to knit every .rmd
file at once? Or do I have to re-knit every single .rmd
for my website?
Update:
To solve this problem you can use the following line of code:
rmarkdown::render_site()
This assumes that all your .rmd
files are in the same directory. See here on page 52 for more information.
Just in case anyone reads this again, I wanted to mention blogdown
since this is a popular package for creating blogs with R Markdown. See here and here.
Upvotes: 2
Views: 4818
Reputation: 44977
To render a list of documents, first you need to put the document names in a variable. One way to do that is
files <- list.files(pattern = "[.]rmd$")
This assumes your files are named *.rmd
. If they are *.Rmd
, modify accordingly.
Then to render them all, just use a for
loop:
for (f in files) rmarkdown::render(f)
This assumes you have the headers all set up to define the output you want. Set the output_format
argument to render()
if you want to override that.
Upvotes: 6