You can host your book on GitHub for free via GitHub Pages (https://pages.github.com). GitHub supports Jekyll (http://jekyllrb.com), a static website builder, to build a website from Markdown files. That may be the more common use case of GitHub Pages, but GitHub also supports arbitrary static HTML files, so you can just host the HTML output files of your book on GitHub. The key is to create a hidden file .nojekyll that tells GitHub that your website is not to be built via Jekyll, since the bookdown HTML output is already a standalone website.

# assume you have initialized the git repository,
# and are under the directory of the book repository now

# create a hidden file .nojekyll
touch .nojekyll

# add to git here because will not show up in RStudio
git add .nojekyll

If you are on Windows, you may not have the touch command, and you can create the file in R using file.create('.nojekyll').

One approach is to publish your book as a GitHub Pages site from a /docs folder on your masterbranch as described in GitHub Help. First, set the output directory of your book to be /docs by

  1. adding the line output_dir: "docs"

  2. to the configuration file _bookdown.yml.

  3. Then, after pushing your changes to GitHub,

  4. go to your repository’s settings and

  5. under “GitHub Pages” tab

  6. change the “Source”

  7. to be “master branch /docs folder”.

In this case, the .nojekyll file has to be in the /docs folder.

#create.file("docs/", ".nojekyll")