- Create git repo
- Clone git repo
- Install gitbook-cli if not setup already
npm install -g gitbook-cli
gitbook help
to verify
- Go inside repo folder
gitbook init
- Verify by using
gitbook serve
- Add .gitignore https://github.com/github/gitignore/blob/master/GitBook.gitignore
- Push all the above to master
- Create
gh-pages
branch
- Push to remote
- Checkout master
npm init
npm i gulp gulp-gh-pages gulp-load-plugins --save-dev
- Crete a
gulpfile.js
and add the following to it
const gulp = require('gulp');
const gulpLoadPlugins = require('gulp-load-plugins');
const $ = gulpLoadPlugins();
gulp.task('publish', () => {
console.log('Publish Gitbook (_book) to Github Pages');
return gulp.src('./_book/**/*')
.pipe($.ghPages({
origin: 'origin',
branch: 'gh-pages'
}));
});
- Run
gulp publish
or add the following to script section in package.json
"serve": "gitbook serve",
"publish": "node_modules/.bin/gulp publish"