Rendering an R Markdown Presentation to GitLab Pages

[This article was first published on R | datawookie, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
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.

To leave a comment for the author, please follow the link and comment on their blog: R | datawookie.

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.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)