bookdown

Slides

Download slide .Rmd

Key Slides
Full slide deck 🖼
Outline 🗓
Get started ☁️ or 💻
Publishing 🚀

Activities

Activity Time
📤 Your turn #1: Edit your index.Rmd YAML 🕝 03:00 minutes
📤 Your turn #2: Add new YAML metadata tags to your index.Rmd 🕝 03:00 minutes
📤 Your turn #3: Add/edit chapters in your book 🕝 10:00 minutes
📤 Your turn #4: Change how your sidebar TOC looks & works 🕝 05:00 minutes
📤 Your turn #5: Tune the book output & publish 🕝 15:00 minutes

Enable Continuous Integration with Travis-CI

  1. In Travis:

    • Enable continuous integration for your book’s GitHub repo on Travis
  2. Modify .gitignore to include these files as “ignored” by Git:

    • _book (unless you had changed the bookdown default output_dir to something else in your _bookdown.yml file)
    • _bookdown_files
  3. Add a file named DESCRIPTION (no file extension needed)

    Package: placeholder
    Type: Book
    Title: Does not matter.
    Version: 0.0.1
    Imports: bookdown, ggplot2
    Remotes: rstudio/bookdown
    
  4. Add a .travis.yml file

  # R for travis: see documentation at https://docs.travis-ci.com/user/languages/r
  
  language: R
  sudo: false
  cache:
  packages: true
  
  script:
  - Rscript -e 'bookdown::render_book("index.Rmd", "bookdown::gitbook")'
  
  deploy:
  provider: pages
  local_dir: _book
  skip_cleanup: true
  keep-history: true
  github_token: $stat545_GITHUB_PAT
  target_branch: gh-pages

You could now deploy this book either using GitHub Pages or Netlify.

Travis-CI to GitHub Pages

  1. In your repo on GitHub, go to Settings > GitHub Pages.
  2. For Source, choose gh-pages branch.

Travis-CI to Netlify

  1. Log in to Netlify
  2. New Site from Git, select your repository
  3. From “Branch to deploy”, select gh-pages branch.
  4. Leave the basic build settings blank (build command and publish directory)
    • This is because in our .travis.yml, we set local_dir: _book. This means that we had Travis only push the rendered _book directory to the gh-pages branch. Check it out in that branch in your GitHub repo! You’ll see all the files there that are present locally in your _book folder.

Enable Continuous Integration with Travis-CI and Continuous Deployment with Netlify