Search code examples
rbookdown

Set R bookdown input directory


I'd like to use bookdown to parse a series of .Rmd file into a book. If I have my .Rmd in the same directory as the main index.Rmd file then everything works fine and dandy. However, the .Rmd files are autogenerated from another source and I'd like to keep the input files in a subdirectory. Is it possible to do that?

I can include the file names in _bookdown.yml but I'd prefer not having to update that file every time a new .Rmd file is added.

The current version of _bookdown.yml looks like this

new_session: yes
rmd_files:
  html: ["input/index.Rmd", "input/01-file.Rmd"]
  latex: ["input/index.Rmd", "input/01-file.Rmd"]

I can move the files in a script but was hoping it was possible through bookdown itself.


Solution

  • In the development version of bookdown you can now provide a list of subdirectories to be search recursively.

    For example to have it search dir1/ and dir2/ (and their subdirectories) you can specify rmd_subdir: ["dir1/", "dir2/"] in the _bookdown.yml.