Shiqiang Jin

# How to build a bookdown by github pages?

### 2019-04-19

Publishing your notes and books via bookdown in the github is free and easy. Here is my note for me to record how to do it.

• Deploy bookdown in Rstudio:

• Build a new project for bookdown from R studio in the folder, such as “~/Dropbox/sjin-blog/bayeslm”.

• After your bookdown project is created, open ‘_bookdown.yml’ Files, then in the last line add:

output_dir: “docs”

• Drop down Build button, and click Build All; You will see a “docs” folder inside the folder of ~/Dropbox/sjin-blog/bayeslm. The content of the bookdown page is then inside the /bayeslm folder.

• Possibly there is an error saying that packages.bib is not found. In this case, go to /bayeslm/index.Rmd file, you will see this line bibliography: [book.bib, packages.bib] at 7th line; check if both files are in the folder of /bayeslm. If there there is no packages.bib file in /bayeslm folder, delete it and leave bibliography: [book.bib] in index.Rmd. Alternative way is to create this missing file, such as copy book.bib and rename it to packages.bib if you do need this bibliography.

• Create an empty reopsitory in Github:

• Create a new repository, for example named as “bayeslm”

• Push local files into github

• Open a terminal, input the following codes:
$cd ~/Dropbox/sjin-blog/bayeslm/docs$ touch .nojekyll
$cd ..$ git add .
$git commit -m "initial commit"$ git remote add bayeslm https://github.com/yourusername/bayeslm.git
\$ git push -u bayeslm master