Making a website in RStudio

I’ve always thought I should eventually have a professional website for job hunting, but recently I’ve realized that it would be nice to have somewhere to collect my thoughts and contributions all in one place. Before having a website of my own, I generally shared updates and thoughts on Twitter and on other people’s blogs, which I will still continue to do, but having everything I do in one place seems like a good idea. I kept putting off making a website until I was recently encouraged by a combination of envy of my officemate’s awesome looking website, and learning that one could make a website using R Studio and the blogdown R package. I just spent a semester learning a ton about R Markdown, the file type blogdown uses to construct websites, for a biostatistics course I was teaching, so I figured using R Markdown to make a website would be relatively easy. Fortunately, I was correct! I spent about 3-4 work days initially getting this website working and customized, and it was relatively painless. Compared to, say WordPress, the impressiveness-to-effort ratio is much higher, in my opinion.

Getting started with Blogdown

Basically blogdown builds a website from a series of Markdown or R Markdown documents. Markdown and the more R-specific version, R Markdown, are really simple languages for creating formatted HTML documents. For example, you can create headers like the one at the start of this paragraph simply by adding different numbers of “#”, and turn a word into a link with square brackets followed by a URL. When the Markdown is converted to HTML, those special characters get converted into the relevant HTML code. Blogdown adds some features to R Studio that make it easier to import themes to help you get started, write new blog posts, and view changes to your website “live.”

The tutorial for blogdown is great, but I found that choosing a theme early on was important, because a lot of what I needed to learn and figure out was specific to the theme. In fact, using blogdown wasn’t really as helpful as I thought for editing the theme I chose, as the example pages in the theme were written in a different format (Markdown with TOML headers) than the default for a new blogdown post (R Markdown with YAML header). That being said, the example Markdown documents that came with the theme were well annotated and for the most part all I had to do was fiddle around with values and add my own text and images.

Building and Hosting a website

I decided to go with blogdown’s recommendation to build and host my website using Netlify. The tutorials on Netlify are very jargon-y and I got basically nothing out of them. Fortunately, the chapter on Netlify in the blogdown book was very helpful. Netlify builds your website from a GitHub repository containing all the Markdown or R Markdown files you’ve created. Fortunately, I had just recently figured out (after much failure) how to link GitHub to R Studio thanks to Jenny Bryan, so it was just a matter of pushing updates to my website to GitHub and following the blogdown tutorial to build the website.

Want to make a website? Just try it!

All of this was completely free, and if you have some knowledge of R Markdown it is super easy to get started. Even if you’ve never used R Markdown, it’s not hard to learn. Depending on the theme you choose, you could get a website up and running in a day or two easily. Feel free to check out the source documents for this website. I think you’ll find that they are not as intimidating as you might think!

Related

comments powered by Disqus