Silvia Canelón


March 16, 2021

R-Ladies Talk R-Ladies template files R-Ladies template slides

This post was featured in the RStudio Blog R Views under a revised title: Deploying xaringan Slides with GitHub Pages. The original title was “Deploying xaringan Slides: A Ten-Step GitHub Pages Workflow.” Other changes include an introductory paragraph and greater clarity in the “Choose your own adventure” section. Many thanks to Chief Editor Joe Rickert for a very encouraging and helpful editorial process! I am humbled by his note on R Views:

Silvia’s post is a mini masterpiece of clear, concise writing that elucidates complex technology within the narrow context of explaining a single well-defined task. Silvia does not attempt to say everything she knows about the subject, and she resists digressions that might obscure the path she is laying out. It is an example of achieving clarity through saying less.

This post will guide you step-by-step through the process of creating an HTML xaringan slide deck and deploying it to the web for easy sharing with others. We will be using the xaringan package to build the slide deck, GitHub to help us host our slides for free with GitHub Pages, and the usethis package to help us out along the way. You will get the most out of this workflow if you are already familiar with R Markdown and GitHub, and if you have already connected RStudio (or your preferred IDE) to Git and GitHub.1 The post will not cover the nuts and bolts of xaringan or talk about slide design & customization, but you can find lots of learning resources listed at the end.

Choose your own adventure

  • Option 1: Start at the beginning of the workflow to make a slide deck using the R Markdown template built into the xaringan package. The built-in template doubles as documentation for the xaringan package, so it is a great way to familiarize yourself with the package features, but it also includes a lot of content that you will probably want to remove and modify when creating your presentation.

  • Option 2: Start with an R-Ladies themed xaringan template (embedded below). This is an example slide deck originally created as a teaching tool to highlight some of the main features of the xaringan package, and to demo some customization that incorporates the R-Ladies CSS theme built into xaringan. Please feel welcome to use/modify it to suit your needs! When you are ready, you can follow the steps immediately below 👇 to download the files to your machine, and then skip down to Initialize version control with git.

  repo_spec = "spcanelon/RLadies-xaringan-template",
  destdir = "filepath/for/your/presentation"

Note: After copying the files to your machine you’ll probably want to rename the file folder to whatever makes sense for your presentation.

Try navigating through the slides ☝️ with your left/right arrow keys and press the letter “P” on your keyboard to see some notes in Presenter View

The Ten-Step Workflow


This workflow was developed using:

Software / package Version
R 4.0.3
RStudio 1.4.1103
xaringan 0.19
usethis 2.0.0

Creating your xaringan slide deck

1. Create a new RStudio project for your presentation:


📍 If you’re not sure where you are on your computer, check your working directory with getwd() and use it as a filepath reference point

2. Create a xaringan deck using a xaringan template:
File > New File > R Markdown > From Template > Ninja Presentation > OK

3. Delete what you don’t need and save your R Markdown file with whatever name you like. If you pick index.Rmd the live link you share at the end will be relatively short.

4. Render HTML slides from the open Rmd file using xaringan’s infinite moon reader:


Initialize version control with git

5. Initialize version control of your slides with git:


You’ll be asked if you want to commit the files in your project (with the message “Initial commit”) and then if you want to restart to activate the Git pane. Say yes to both ✅

Note: At the moment usethis names the primary branch “master” by default. Issue #1341 suggests the option to instead name it “main” is in the works.

6. Connect your local project with a GitHub repo:


You could use the function argument private = TRUE to create a private GitHub repository. But you may have to remember to change the visibility before deploying to GitHub Pages.

7. Your new GitHub repo with all of your xaringan project files will automatically open up in your browser

Repo for the R-Ladies xaringan template:

Making and committing changes to your slides

8. Edit your slides as you wish. Commit often! And then push to GitHub. Use the tools provided by the Git pane in RStudio, or use the following commands in the Terminal:

# Step 1: Stage all modified files
git add .
# Step 2: Describe the changes you made to your files
git commit -m "<A brief but descriptive commit message>"

Consider writing a commit message that finishes the following sentence:2 “If applied, this commit will…” (e.g. “Change the slide theme,” “Add hello slide”)

# Step 3: Push the changes to your GitHub repository
git push

Deploying your slides

9. When you’re ready to deploy your slides, you can use the usethis::use_github_pages() function which makes the process of deploying via GitHub Pages super easy. I recommend pointing branch to the name of your primary branch.

usethis::use_github_pages(branch = "master")

Note: Your repository must be public for your deployed slides to be available publicly, unless you have a paid GitHub account.

Also, you only need to follow this step once to deploy your slides to the web. As long as you remember to push to your repo any changes that you make to your slides (Rmd and HTML), GitHub Pages will know how to render them.

10. Visit the link provided to see your newly deployed slides! 🚀
Don’t panic if you don’t see them right away, sometimes it takes a little time. This is the link you will share with the world when you present. Notice it looks very similar to your GitHub repo link.

Link to the R-Ladies xaringan template rendered slides:

Bonus steps

11. Go to the repository home page and find the About section on the right hand side. Add a description of your presentation and the link to your slides, that way your presentation is easily available to anyone visiting your repo.

12. Check out Garrick Aden-Buie’s blog post Sharing Your xaringan Slides to learn how to create a social media card for your slides and use your new link to share your slides in more places (e.g. embedded on a website, etc.)

13. This GitHub Pages workflow is not exclusive to xaringan slides! Try it out with any other HTML file.

Learn more


Sharing your slides

Making your slides extra special

Back to top


  1. Chapter 12 Connect RStudio to Git and GitHub | Happy Git and GitHub for the useR↩︎

  2. How to Write a Git Commit Message | Chris Beams↩︎



For attribution, please cite this work as:
Canelón, Silvia. 2021. “Deploying Xaringan Slides with GitHub Pages.” March 16, 2021.