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 linebibliography: [book.bib, packages.bib]
at 7th line; check if both files are in the folder of/bayeslm
. If there there is nopackages.bib
file in/bayeslm
folder, delete it and leavebibliography: [book.bib]
inindex.Rmd
. Alternative way is to create this missing file, such as copybook.bib
and rename it topackages.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
Username for 'https://github.com': your user name
Password for 'https://yourusername@github.com': your password
- Setup GitHub:
- After pushing files to Github, go to repository’s settings and under GitHub Pages change the Source as master branch /docs folder.
Within one minute, the website will be deployed at https://calebsjin.github.io/bayeslm/.