In our September meetup hosted at the Penn Dental School, R-Ladies LA founder and recent Philadelphia transplant Dr. Katie Scranton led an interactive workshop on making websites (like this one!) using R and the blogdown package.
Katie started off by providing a broad overview of how blogdown works. Blogdown generates websites using Rmarkdown documents, and each blogdown website consists of a single folder of static files. Once created, your blogdown website can then be hosted on any web server to make it ‘live.’
Next, Katie live-coded website creation in R using blogdown. We worked in parallel on our laptops, so that each meetup attendee left with their own website. Here, we go over some of the essential steps in this process!
First, we installed blogdown and Hugo. Hugo is the default site generator in blogdown:
install.packages(blogdown) library(blogdown) blogdown::install_hugo()
Next, we each chose a Hugo theme for our website and used this theme to create a new, blank site in our current working directory:
# create blank website with the Hugo 'Academic' theme blogdown::new_site(theme = "gcushen/hugo-academic") # view your website layout in the RStudio Viewer blogdown::serve_site()
Aside from aesthetic preferences, choosing an appropriate theme for your website involves consideration of your website’s purpose. For example, is it an academic website, a blog, or a general informational website (e.g. for a company or business)? Chances are, there is a theme to best suit your website’s purpose.
The files for your website now live in your current working directory:
# see all the files that blogdown::new_site() created list.files()
Then, Katie showed us how to customize our website focusing on the
config.toml file that configures the settings for our website:
# open the config.toml file to edit file.edit('config.toml')
content/ folder that - as you might have guessed - includes the content of our website:
For example, if we were to create a blogpost for our website using blogdown, this file would automatically appear in
blogdown::new_post(title = "my_first_post")
Once created, your website files can be uploaded to any webserver. We use github for rladiesphilly.org - to learn more about web hosting and version control, see our May meetup recap. You can see the code used to generate this website hosted on our blog github repo here.
To end our workshop and inspire further refinement of our websites, Katie showed us her personal website created using blogdown.
Katie suggests the following resources to learn more:
her meetup summary
this post from Alison Presmanes Hill
this post from Mara Averick
this guide from R-Ladies Melbourne
Thanks again to Katie for leading this informative meetup, and to Penn Dental for hosting R-Ladies Philly!
This post was authored by Katerina Placek. For more information contact email@example.com