Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call Javascripts into rmarkdown yaml

I want to use this to create an html that resembles the grayscale bootstrap site's lay-out using Rmarkdown V2.

I can load the css by using in my yaml:

output:
html_document:
css: css/grayscale.css

But how do I load the rest of the files into the rmarkdown yaml?

The folder examples from the site above are all in a consistent format (css, js, fonts, img) but I cannot seem to get my rmarkdown to call either the js scripts or the images? Should this be done in the yaml?

Help please?

like image 966
Nick Avatar asked Mar 17 '26 04:03

Nick


1 Answers

bookdown::html_document2 has an option includes here you can set e.g. in_header to an html file that contains what you need. At least for JavaScript its working for me.

output:
  bookdown::html_document2:
    includes:
      in_header: "javascript.html"

https://bookdown.org/yihui/bookdown/yaml-options.html#yaml-options

like image 81
Patrick Avatar answered Mar 18 '26 17:03

Patrick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!