Creating free online ebooks with bookdown

Author

Martin Schweinberger

Creating Bookdown Websites: A Step-by-Step Guide

Publishing an ebook or web-based script using RStudio and GitHub is straightforward with the bookdown package. This tutorial walks you through the process of creating a Bookdown website, adapted from a helpful template by GitHub user jtr13. The result is a flexible, version-controlled site ideal for sharing tutorials, course materials, or research outputs.

Prerequisites

Before you start, make sure you have:

  • A GitHub account
  • Git installed and configured on your machine
  • R and RStudio installed
  • The bookdown package (install via install.packages("bookdown"))

Step-by-Step Instructions

1. Set Up Your GitHub Repository

  1. Log in to GitHub.

  2. Visit the Bookdown template: https://github.com/jtr13/bookdown-template

  3. Click Use this templateCreate a new repository.

  4. Go to your repository’s SettingsPages.

  • Under Build and deployment, set:
    • Source: Deploy from a branch
    • Branch: main, and folder: /docs
  • Click Save. A URL will appear showing where your site will be published. Copy this for later.
  1. Back on your repository homepage, click the gear icon near the About section, and paste the copied site URL into the Website field.

2. Clone Your Repository in RStudio

  1. In RStudio:
    Go to FileNew ProjectVersion ControlGit.

  2. Paste your repo’s HTTPS link (from the green Code button on GitHub) into the Repository URL field.

  3. Choose a local directory to store the project and click Create Project.

3. Customize Your Book

Open the project in RStudio and modify the template files:

  • In index.Rmd:

    • Replace "YOUR TITLE HERE" with your book’s title.

    • Replace "YOUR NAMES HERE" with your name(s).

  • In _bookdown.yml:

    • Replace "YOUR GITHUB USERNAME" with your GitHub username (2x).

    • Replace "YOUR GITHUB REPO" with your GitHub repository name (2x).

  • In _output.yml:

    • Replace "YOUR SHORT TITLE" with a shortened version of your book title.

    • Leave the "after:" line as is—it credits Bookdown.

4. Build and Preview the Book

Install or update bookdown:

install.packages("bookdown")

Render the book by:

  • Running bookdown::render_book("index.Rmd") in the console

or

  • Clicking Build Book in the Build tab in RStudio

To view your book locally:

browseURL("docs/index.html")

Or manually open docs/index.html in your web browser.

5. Publish to GitHub Pages

Once everything looks good:

  1. In the Git tab in RStudio, commit and push your changes:
  • StageCommitPush
  1. Wait about a minute, then visit your site’s GitHub Pages URL (from Step 1.4).
    Your book should now be live!

6. Final Touches

  1. Open README.md in RStudio or edit directly on GitHub.

  2. Replace the placeholder content with:

  • A short description of your project

  • A link to your published Bookdown site

Updating Your Book

Whenever you make changes:

  1. Re-render the book

  2. Commit and push the updated files to GitHub

  3. Wait a minute or two for the changes to appear live

Additional Tips

  • To allow easy editing/viewing of .Rmd files on GitHub, keep paths in _bookdown.yml updated if you move files around.

  • To change the appearance of your book, edit style.css or add configurations in _output.yml.

By following these steps, you can quickly create and publish your own professional-looking web-based ebook using Bookdown and GitHub Pages—for free.

Citation & Session Info

Schweinberger, Martin. 2025. Creating free online ebooks with bookdown. Brisbane: The University of Queensland. url: https://ladal.edu.au/tutorials/bookdown/bookdown.html (Version 2025.08.05).

@manual{schweinberger2025notebooks,
  author = {Schweinberger, Martin},
  title = {Creating free online ebooks with bookdown},
  note = {tutorials/bookdown/bookdown.html},
  year = {2025},
  organization = {The University of Queensland, School of Languages and Cultures},
  address = {Brisbane},
  edition = {2025.08.05}
}
sessionInfo()
R version 4.4.2 (2024-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26100)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8 
[2] LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: Australia/Brisbane
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

loaded via a namespace (and not attached):
 [1] htmlwidgets_1.6.4 compiler_4.4.2    fastmap_1.2.0     cli_3.6.4        
 [5] htmltools_0.5.8.1 tools_4.4.2       rstudioapi_0.17.1 yaml_2.3.10      
 [9] rmarkdown_2.29    knitr_1.49        jsonlite_1.9.0    xfun_0.51        
[13] digest_0.6.37     rlang_1.1.5       renv_1.1.1        evaluate_1.0.3   

Back to top

Back to HOME