Part 9 Creating Bookdown Websites

Generating webpages in RStudio and via GitHub is very easy to do and offers various options for researchers and teachers. Here, I’ll outline the process I used to create an online webscript, primarily relying on resources and documentation provided by GitHub user jtr13.

  1. Log in to GitHub.

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

  3. Click on Use this template.

  4. On your repository’s home page, navigate to Settings. Then, go to the Pages section on the left. Under Build and Deployment, set Source to Deploy from a branch and Branch to main with /docs folder. Click Save. A box will appear above the Build and Deployment section with your book’s URL. Copy the URL.

  5. Near “About” on the home page of your repo, click the gear button and paste your book URL into the Website field that appears on the right.

  6. Click the green Code button and copy the HTTPS link, formatted like this: https://github.com/[USERNAME]/[REPO NAME].git.

  7. Clone your new repo in RStudio via File -> New Project -> Version Control -> Git. Paste the link from the previous step in the Repository URL box.

  8. In index.Rmd, replace “YOUR TITLE HERE” with your title.

  9. In index.Rmd, replace “YOUR NAMES HERE” with your names.

  10. In _bookdown.yml, replace “YOUR GITHUB USERNAME” with your GitHub username in the two instances.

  11. In _bookdown.yml, replace “YOUR GITHUB REPO” with your GitHub repo name in the two instances. Note that steps 3 and 4 provide links to the .Rmd files of your project for editing and viewing. Update these file paths if you move your .Rmd files. Once your book is rendered, test that the edit (pen) and view (eye) buttons work.

  12. In _output.yml, change “YOUR SHORT TITLE” to a shortened version of your title. Leave the “after:” line indicating that the book was published with bookdown unchanged.

  13. Install bookdown with install.packages("bookdown"). If you already have it, update to the latest version.

  14. Render locally with bookdown::render_book("index.Rmd") or by clicking the Build book button in the Build tab.

  15. Use browseURL("docs/index.html") to view your book locally or open index.html in a browser.

  16. If everything looks good, commit and push all changed files to GitHub. Note that you’ll need to repeat steps 2 and 4 every time you wish to update the online book.

  17. Edit README (GitHub or RStudio): Once you’ve completed these steps, delete the content of this README and add a brief description of your project with a link to the book URL.