Akik A wave is not a wave

Please indicate the source and keep the original link (github.com/riskers/blo…) And author information.

This article will teach you how to gracefully publish books on Github Pages using GitBook + Travis.

Template: github.com/riskers/git…

Effect: riskers. Making. IO/gitbook – tem…

The project structure

Git clone https://github.com/riskers/gitbook-template CD gitbbok - template && rm - rf. Git # remove the historical record in the templateCopy the code

Modifying a template:

  • .travis.yml:
    • Exerts: Modified to your email
    • REF: Change the Github address of your project
  • book.json: Modifying the gitBook configuration is not the focus here. See the configuration results.Riskers. Making. IO/gitbook – tem…
  • chap01chap02The correspondingSUMMARY.mdThat’s what this book is about.

Then create a new project on Github and push it, and you can see the project structure like this:

github pages

If you have not signed up for github Pages, you need to register first.

Create gh-Pages branch:

git checkout -b gh-pages
git push origin gh-pages
Copy the code

Enable GitHub Pages service in project Settings -> GitHub Pages:

Travis

Enable the Travis service for this project: github.com/marketplace…

Finally you should see this screen:

Apply for a token in the personal Settings to give Travis the right to change the project:

Then select repO and click the Build button:

Duplicate the generated token and fill in Travis’s Settings – Global variables and name it token:

Try the effect

Add a line:

Then push up and you can see Travis CI running:

After a short wait, you can see Travis CI pushing the gitbook build to us under GH-Pages:

Can be in making pages riskers. Making. IO/gitbook – tem… To see the effect:

Done!

subsequent

Recently, I used Gitbook to write an e-book, and found that if there are more than two books, it will be charged, while the old version is not charged, so I have been using the old version recently. But perhaps due to the lack of maintenance, the synchronization of the old version was not timely, so I abandoned the Gitbook service.

I wanted to build gitbook locally and then push it to pages service, but it was too inelegant, so I figured out how to use CI to do this. I had been working on GitLab CI in my company for a while, and I solved it quickly.

So far, I have written md on master and pushed it to master, and Travis automatically executes the Gitbook build and pushes the generated document to gh-Pages for the Pages service to work. It’s fully automatic, isn’t it elegant? Ha ha.

By the way, both books are written this way:

  • rxjs-note: riskers.github.io/rxjs-note/
  • Flutter – notebook: riskers. Making. IO/flutter – not…

Donations to me | | about me job opportunity