preface

Learning a technology, we can write an e-book to sort out the whole knowledge system, and then deepen understanding and memory.

First, install Node NPM

Check the node version
node -v

# Check the NPM version
npm -v
Copy the code

If you print this number successfully, it indicates that you have a local running environment for Node (NPM is installed by default when installing Node). If no or an error is reported, you need to download and install Node from the official website of Node, as shown in the figure below:

The version on the left is the recommended stable version, which is currently officially standard, while the version on the right is the latest version, which contains some new features that are not fully standard yet and may change later. You are advised to install the latest Stable version of Node for development.

Recommend using NPM taobao

npm config set registry https://registry.npm.taobao.org/
Copy the code

Step 2: Install gitbook globally – CLI

npm i -g gitbook-cli
Copy the code

Step 3: Initialize the ebook

Create a directory and enter
mkdir gitbook-demo
cd gitbook-demo

Initialize the ebook catalog
gitbook init 

# Compile ebooks
gitbook serve 
Copy the code

To clarify:

Md is a brief introduction to the ebook, and summary. md is the directory structure of the ebook.

The directory structure looks like this:

* [ebook name](readme.md) * [chapter1](chapter1/ readme.md) * [XXXX](chapter1/section1.1.md) * [XXXX](chapter1/section1.2.md) * [chapter2](chapter2/section2.1.md) * [XXXX](chapter2/section2.2.md) * [XXXX](chapter2/section2.2.md)Copy the code

Write summary.md, execute gitbook init to generate directory structure files, and then write the files generated in each folder.

Finally gitbook serve.

The gitbook Serve command actually calls Gitbook build first to compile the book, and when it’s done it opens a Web server that listens on port 4000 locally.

Small development

You can submit your ebook to Github, set up a Gh-Pages branch in the repository that hosts your ebook, and upload locally compiled ebook files (files in the _book directory at the root of your project) to this branch. Then you can use this url to http://yourUserName.github.io/bookName.

You can also post to Gitbook, but the site is a bit slow to access

talking

There are a lot of tools for making e-books. You might as well talk about your common tools in the discussion section

Even better, attach your own ebook url. –