rr-markdownrender

How to render a "github_document" Rmd without generating the HTML preview?


I'm maintaining a package and have to rebuild the README.Rmd file every once in a while.

Using the "knit" button in RStudio, the effect is correct: the file README.md is generated at the root of the package, and a README.html preview is created in a temporary file and opened.

However, if I use the following command, the HTML preview is created at the root of the package, which is unnecessary.

rmarkdown::render(input="README.Rmd")

How to tell this preview file to be temporary, or even to not bother to exist at all?

I tried to set intermediates_dir=tempfile() with no effect, and I couldn't find what command RStudio is running on "knit" push. Moreover, it seems that this simple command does not have this side effect when run through Github Actions (link).

PS: Here is a minimal example of my Rmarkdown file (whole file here):

---
  output: github_document
---

Hello Word

Solution

  • Set the html_preview option to false, like so:

    ---
    output:
      github_document:
        html_preview: false
    ---
    
    Hello World
    

    This option is documented here. BTW, I suspect that a .html file is generated on the server where the render-rmarkdown action is performed; you don't see it locally because the action only commits changes to .md files:

    $ git commit ${RMD_PATH[*]/.Rmd/.md} -m 'Re-build Rmarkdown files' || echo "No changes to commit"