Member-only story
Distilling a website
To accompany my book, I created a website using the distill package.
With David Spiegelhalter, I co-authored a book of Covid-19 statistics. For the book, I wanted to create a website hosting the graph code, reviews, and purchase links. Some elements of this site remain a work in progress.
Using R Markdown, one package and limited coding can produce a site. This site had several specifications:
- Several different pages.
- A navigation bar linking to these pages.
- The ability to host images and link to code.
- Customisation of fonts and colours.
Creating the website
After setting up the GitHub pages site, you can create a new site in a single command:
library(distill)
create_website(dir = "my-website", title = "My Website")
That code makes three files: a home page, an ‘about’ page, and a configuration file. We should look at the configuration for the accompanying website:
name: "covid-by-numbers"
title: "Covid by Numbers"
description: |
Covid by Numbers
output_dir: "docs"
navbar:
logo:
image: images/logo.png
href: https://covid-by-numbers.github.io/
right:
- text: "Code"
menu…