Building a website with Distill for RMarkdown

This tutorial aims to provide you a step-by-step guide to build a web blog by using Distill for R Markdown package.

Dr. KAM Tin Seong,
Associate Professor of Information Systems (Practice) https://www.smu.edu.sg/faculty/profile/9618/KAM-Tin-Seong
01-06-2021

Getting Started

Installing distill

Before you getting started, you need to install distill.

install.packages("distill")

To learn more about what functions and features offer by distill, you should visit the homepage of distill for R Markdown at least once. The homepage provides a comprehensive discussion on the features and functions of distill.

Opening github and Netlify accounts

In this tutorial, github will be used to host the blog post and will be deploy via Netlify. To create an account, please visit their respective homepage below:

Start a New Website Project

To start a new website project,

The New Project Wizard appears.

Your screen should look similar to the screenshot below.

Let us examine the Files window of RStudio as shown in the screenshot below. The home-directory is called DA. It consists of the DA.rproj file, the about.rmd file, the index.rmd file, the *_site.yml* file and *_site. The _site* folder contains all the final html files and other libraries required to build the web page.

Viewing the newly created blog page

Next, let us view the newly created blog page.

A web page appears on RStudio viewer as shown below.

Congratulations! Your first web blog has been built successfully.

Editing the _site.yml Page

You screen should look similar to the screenshot below.

The _site.yml is where we control the content of the blog that include the name, title, descriptive, and the navigation bars.

We will add two new navigation bars on the left. One for DataViz Makeover and one of Take-home Exercise.

To update the change, you can either

Alternatively, the code chunk below should be used.

rmarkdown::render_site()

Note: It is important to perform either one of the above step when *_site.yml* is edited.

Notice that two new navigation bars are added on the website.

Editing about.rmd

In this section, you will learn how to edit the about.rmd file and update its corresponding html page.

Your screen will look similar to the screenshot below.

This is the default about page. Let us edit the about.rmd similar to the screenshot below.

The About page of the blog will look similar to the screenshot below.

Starting Git

In this section, you will learn how to start a git service in RStudio by using use_git() of usethis package.

Note: Use the code chunk below to install usethis if it has yet to be installed in your computer.

install.packages("usethis")

Next, you will edit the code chunk below on RStudio Console.

usethis::use_git()

The follow message appears.

At this stage, we are not ready to commit the edition.

The follow message appears.

We are going to re-start RStudio.

The Switch Projects dialog window appears.

Notice that Git tab has been added on RStudio pane.

Your screen should look similar to the screenshot below.

We are going to commit all changes.

Your screen should look similar to the screenshot below.

Notice that we can not push the commit because we have yet to configured Github.

Configuring and Pushing to Github

In this section, you will learn how to configure Github and push the commit to Github.

usethis::use_github()

Once the operation completed, the Gihtub webpage appears.

Publishing the Blog

In this section, you will learn how to publish the newly create blog on Netlify server.

Note: This sectgion assume that you have already create an account wit Netlify.

Your screen should look similar to the screenshot below.

Your screen should look similar to the screenshot below.

Your screen should look similar to the screenshot below.

When you are ready,

Notice that Netlify will give a temporary and yet weird name.

You can change the name by using the Site settings option.

Your screen should look similar to the screenshot below.

The Change site name dialog window appears.

Notice that the blog page has a new name (i.e. r4dsa) now.