Rendering an R Markdown Presentation to GitLab Pages
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
I’m busy preparing slides for the Why R? conference using the brilliant {xaringan} package along with {xaringanthemer} to tweak the styles. There are plots rendered into the document as well as static images.
I wanted to publish the presentation using GitLab Pages. My first attempt left me with no styles or images, but after a few iterations I had something that works.
This is the contents of my .gitlab-ci.yml file:
image: rocker/verse:4.0.0
before_script:
- R -e "install.packages('xaringanthemer')"
pages:
stage: deploy
script:
- Rscript -e "rmarkdown::render('talk.Rmd', output_file = 'index.html')"
- mkdir public
- cp index.html xaringan-themer.css public/
- cp -r index_files/ fig/ public/
artifacts:
paths:
- public
only:
- master
interruptible: true
GitLab Pages expects the content to be found in the public/ folder. To ensure that the paths to images (static and rendered) are correct, I render the Rmd in the current folder and then copy everything across into public/.
Hopefully this will save you the 30 minutes it took me to figure this all out.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.