Creating a bookdown book with the bs4 theme

A short guide to creating a bookdown book using the bs4 theme

Maximilian Rohde

What is the bs4 theme?

If you’ve been learning R through the amazing free resources made available by the R community, then you probably seen examples of the bs4 bookdown theme in a few of these various sources:

I think the bs4 theme looks better, and is easier to navigate, than the older gitbook theme (example here).

This is a quick guide on how to get started. For comprehensive details, look at the official guide by Yihui Xie, the author of bookdown.

How do you use the bs4 theme?

To follow this tutorial, you need to have the development version of bookdown installed. You can install it with


It will also be helpful to work in RStudio, although it is not strictly necessary.

We will create an example project using the bs4 theme, using a template provided by the developers. Then we can edit this template project to make our bookdown book. To create an example project, enter the following command into the R console within RStudio:


This will create the project in your current directory.

Now, click on the .Rproj file within the project directory to open the project in RStudio. You will see the files of the example like this:

Examples bs4 files

You can then edit the files according to your needs. The first file to start editing is index.rmd, which contains the metadata of the book such as the title, author, date and more. It also contains the content that will go on the landing page for the HTML rendering of the book.

Next you will want to edit files for each chapter, and delete those you don’t need.

Lastly, to fiddle with the theme, you can edit the style.css file if you have some experience with CSS.

To render the book, use


Then to view the preview of the HTML page, use

The final result

To host my bookdown books online, I put the project into a GitHub repository, and then use Netlify to host it for free. However, this is out of the scope of this tutorial. The official guide by Yihui Xie has more details on the hosting process.


If you see mistakes or want to suggest changes, please create an issue on the source repository.


For attribution, please cite this work as

Rohde (2021, Aug. 10). Max Rohde: Creating a bookdown book with the bs4 theme. Retrieved from

BibTeX citation

  author = {Rohde, Maximilian},
  title = {Max Rohde: Creating a bookdown book with the bs4 theme},
  url = {},
  year = {2021}