R Markdown websites provide the perfect opportunity to present projects you are working on. They are based on Rmd scripts that you write to run your analyses, so once you’ve set your website up it is easy to update it as you write your code. The main advantages of rendering your Rmd scripts into a website are:
To build an R Markdown website you will need:
Here we will focus only on building the website, so there are no instructions on how to set up your GitHub account and getting it synced with your local machine.
Note: The name of the mandatory files needs to be exactly as specified above, so that the files are recognized when you use the command rmarkdown::render_site()
to render your website.
The _site.yml
file is used to configure how your website is generated. Below are two examples of _site.yml
files.
Example 1 shows how a _site.yml
file (left), and what the corresponding website (right) looks like. In that example we have the following fields:
text
field immediately aboveExample 2 has a few extra fields, namely:
_site.yml
file. Remember to set the output_dir as “.” (see example 2, above).index.Rmd
file_site.yml
.rmarkdown::render_site()
. Otherwise specify the directory when you execute that command. For example: rmarkdown::render_site(input="/Path/to/directory")
When you finish running these steps, you will have all the files that make up your website in the directory you specified. If you open the index.html
file, for example, you will see a local version of your website.
Once you created your local version of the website, you need to sync the project directory with GitHub. Then, follow the steps below to publish your website:
_site.yml
and index.html
).After a few minutes, your website will be published and the corresponding URL will be displayed in the “GitHub Pages” section in green background (see example below).
Note: It can take up to 20 minutes for changes to your site to publish after you push the changes to GitHub.
Note: Even if your GitHub repository is private, the website will be public, i.e. other people won’t be able to see the files on your GitHub repository but they will be able to see the website if given the link.
There are many features that you can add to your website. Below is a list of links to useful online resources that you can explore to build your R Markdown website.
R Markdown Website instructions
Getting started with R Markdown
Markdown Basics
Intro to R Markdown by Yan, Florian & Baptiste
R Markdown Cheat Sheets
R Markdown Website example1
R Markdown Website example2