Search code examples
rbookdown

What's the difference between `_bookdown.yml`, `_output.yml` and yaml header of the first document?


When authoring a document with bookdown, I am aware of four options to put configuration options:

  • _bookdown.yml
  • _output.yml
  • the yaml header of the first .Rmd document
  • arguments passed to the bookdown::render_book() function.

Now my question:

  • Which options can go where, i.e. can I use all files interchangeably?
  • Which options should go where, i.e. what is good practice to put the configuration options?

Solution

  • so far I know...hope others can complete this

    First have a look at this high level explanation R markdown next use the hyperlinks provided below which all point to the documentation details

    YAML header of the first *.Rmd file

    • can contain additional pandoc parameters as described here.
    • It must contain the following line: site: bookdown::bookdown_site
    • may contain multiple output formats specified by

      output: 
        bookdown::gitbook:
        bookdown::pdf_book:
        bookdown::epub_book:  
      

    ... but these can also be in the _output.yml as described here all formats should be at the top level, instead of under an output field.

    Example

    _bookdown.yml

    All _bookdown.yml parameters used for generating the book and save the results.

    Example

        book_filename: "_book_example"
        repo: https://github.com/<user>/<repo>/ 
        before_chapter_script: ["script1.R"]
        after_chapter_script:  ["script2.R"]
        output_dir: "_book"
        clean: ["deleteme.Rmd"]
        rmd_files: ["index.Rmd", "02-literature.Rmd", "01-intro.Rmd"]
        delete_merged_file: true
        language:
          label: 
            fig: "FIGURE " 
            tab: "TABLE " 
          ui:
            edit: "Edit"
            chapter_name: "Chapter "
        rmd_subdir: ["content/"]