2

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.

tyluRp
  • 4,678
  • 2
  • 17
  • 36

1 Answers1

6

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.

user2554330
  • 37,248
  • 4
  • 43
  • 90
  • Thank you for pointing out `render`, I was able to do what I wanted using the following command: `rmarkdown::render_site()` – tyluRp Feb 13 '17 at 22:08