Chapter 4 Generating your website

This chapter teaches you how to generate a website in three simple steps using RStudio.

Note: This chapter and all subsequent chapters will use the Hugo Anatole theme as the basis for explaining and implementing concepts. Over the course of this book, the default Hugo Anatole website will be edited sequentially to produce the final result which can be viewed here -https://r4sites-anatole-custom.netlify.app/.

4.1 Prerequisites

Before you proceed, complete the following prerequisites:

  1. Install R
  2. Install RStudio
  3. (optional) Discover your style

My recommendation is to download the latest versions, which at the time of this writing are R 4.0 and RStudio 1.4.

4.2 How it works

RStudio’s New Project Wizard makes it remarkably easy to generate a blogdown website in three simple steps. Behind the scenes, RStudio and blogdown use Hugo to generate your website.

4.3 Generate your site

Follow these steps to generate a website using RStudio:

  1. Launch RStudio and install the blogdown package by running install.packages("blogdown") in the R console.

  2. Create a new RStudio Project by going to File > New Project > New Directory > Website using blogdown. Image.

  3. Configure the website to use the Hugo Anatole theme by setting the Hugo theme parameter to lxndrblz/anatole. Click Create Project to generate the website. Image

4.4 Use a different Hugo theme

To use a theme other than Anatole, locate and select the theme from the list of Hugo themes. Click “Download” on the theme homepage to view the source code on GitHub (Image). Copy the user/theme-name in the GitHub URL, then add this information to the Hugo theme parameter in the website configuration. For example, if the source code is located at https://github.com/devcows/hugo-universal-theme, insert devcows/hugo-universal-theme into the Hugo theme parameter.

4.5 Serve the website locally

The blogdown package includes a handy function called serve_site(). Running this function in the R console with your website’s RStudio Project loaded will render a local copy of your entire website in the RStudio “Viewer” pane. Image

The best part of this feature is that as you make and save changes to your website files, the local rendering will update in real-time and reflect your changes. This feature of blogdown, known as LiveReload, empowers you to test ideas and receive instant feedback without having to leave the RStudio environment.

4.6 Next steps

Proceed with fine tuning the look and feel including font styles, colors, and profile images.

Optionally, skip ahead and deploy your website to the internet. Though the steps to deploy your website are covered in a later chapter, readers are welcome to complete these steps at any point following the initial generation of the website.