Search code examples
r-markdownblogdownxaringanremarkjs

Blogdown/Xaringan does not work after using chakra option


I followed the installation process for Xaringan explained by Tim Mastny. Everything worked smoothly and I could produce my first slideshow.

To make the slides work offline, I followed the tips by Yihui Xie. The download with xaringan::summon_remark() went fine and generated the libs folder in my project directory with the file remark-latest.min.js in it. But when I added the chakra option chakra: libs/remark-latest.min.js to the YAML header as describe in the Xaringan slideshow documenation, and called serve_site(), the slideshow did not work anymore.

Instead of the previous working slideshow I got a small window on the left top of my screen which contains the source text of my slideshow. I have seen this window in other occassions as well. For instance in some links from the remark.js website to demo slideshows, e.g. here.

I installed a complete new blogdown website with the Xmin theme and did the installation procedure from scratch. I used the R Markdown "Nina Presentation" template and added just the one chakra line. I received the same result. Just the small window.

I used Google Chrome but tested also with Safari and Firefox with the same result. Has anyone any idea what could be the problem or what I could try next?

My sessionInfo()

R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_3.5.1  backports_1.1.2 bookdown_0.7    magrittr_1.5    rprojroot_1.3-2 htmltools_0.3.6
 [7] tools_3.5.1     yaml_2.1.19     Rcpp_0.12.17    stringi_1.2.4   rmarkdown_1.10  blogdown_0.8   
[13] knitr_1.20      xfun_0.3        stringr_1.3.1   digest_0.6.15   evaluate_0.11  

Solution

  • Found the problem: you summoned remark.js to libs/ in your blogdown project's root directory. Instead, you should summon remark.js to static/slide/libs/ using:

    xaringan::summon_remark(to = "static/slide/libs")
    

    Explaination: Hugo copies all files under "static/" to the root of the compiled website.

    Make sure libs/ sits together with your xaringan source Rmd somewhere under static/ subdirectory, like yours: static/slide/libs, so that the xaringan can find files they need.

    And that remark-latest-min.js should be in static/slide/libs/ too.