Simple use of gitbook


Basic use


Note that users need to install nodejs first, so that they can use NPM to install gitbook.

npm install gitbook -g
//View installed versions
gitbook -V


//Create directory
mkdir pfinal-club
//Initialize books
gitbook init


Use the following command to generate a_bookDirectory, the content of which is the resource file of the static site:

gitbook build

Start the service

Use the following command to run a web service, whichhttp://localhost:4000/You can preview books

gitbook serve

directory structure

Gitbook project structure

Gitbook uses a simple directory structure. In summary (i.eSUMMARY.mdAll markdown / asiidoc files listed in the. The structure of multilingual books is slightly different.

A basic gitbook e-book structure is usually as follows:

├── book.json
├── chapter-1/
|   ├──
|   └──
└── chapter-2/

Document description:

file describe
book.json Configuration data(optional) Introduction to e-books(required) EBook catalog(optional) Vocabulary / annotation term list(optional)


Using gitbookSUMMARY.mdDocument to define the structure of chapters and sub chapters of the book.SUMMARY.mdThe file is used to generate the directory of the book.

SUMMARY.mdThe format is a list of links. The title of the link will be the title of the chapter, and the target of the link is the path of the chapter file.

Adding a nested list to a parent chapter creates a child chapter.


# Summary

* [Part I](part1/
    * [Writing is nice](part1/
    * [GitBook is nice](part1/
* [Part II](part2/
    * [We love feedback](part2/
    * [Better tools for authors](part2/


The table of contents can be divided into headings or horizontal lines----Separated part:

# Summary

### Part I

* [Writing is nice](part1/
* [GitBook is nice](part1/

### Part II

* [We love feedback](part2/
* [Better tools for authors](part2/


* [Last part without title](part3/

Parts is just a chapter group, there is no dedicated page, but it will be displayed in the navigation according to the topic.

Common commands

  1. Gitbook help / / lists all the commands in gitbook
  2. Gitbook — help / / output help information of gitbook cli
  3. Gitbook build / / generate static web pages
  4. Gitbook serve / / generate static web pages and run the server
  5. Gitbook update / / update to the latest version of gitbook
to configure

Configure inbook.jsonFile. Here is a standard configuration file.

It needs to be implementedgitbook installInstall the plug-ins in the configuration file

"Title": "pfinal community,",
    "Description": "Introduction to pfinal community,",
    "Author": "Nancheng",
    "": "site",
    "language": "zh-hans",
    "gitbook": "3.2.3",
    "root": ".",
    "structure": {
        "readme": ""
    "links": {
        "sidebar": {
            "Pfinal community":“ "
    "plugins": [
        "[email protected]^0.0.11",
        "[email protected]^0.1.1",
        "[email protected]^2.0.0",
        "[email protected]",
        "[email protected]^2.0.2",
        "[email protected]^0.1.0",
        "[email protected]^2.1.0",
        "[email protected]^0.0.2",
        "[email protected]^0.2.1",
        "[email protected]^0.7.1",
        "[email protected]^3.0.2",
        "[email protected]^0.3.2",
        "[email protected]^1.1.0",
        "[email protected]^1.1.3",
        "[email protected]^0.0.8",
        "[email protected]",
        "[email protected]^0.0.1",
        "[email protected]^0.1.7",
        "[email protected]^3.1.0",
        "[email protected]^1.0.2",
        "[email protected]^1.0.1",
        "[email protected]^0.1.1",
        "[email protected]",
        "[email protected]^0.0.2",
        "[email protected]^0.1.3",
        "[email protected]^0.9.0",
        "[email protected]^0.3.2",
        "[email protected]^0.2.0",
        "[email protected]^0.1.0",
        "[email protected]^1.0.1",
        "[email protected]^1.0.2",
        "[email protected]^1.2.0",
        "[email protected]^0.1.1",
        "[email protected]^3.0.2",
        "[email protected]^0.0.2",
        "[email protected]^0.1.0",
        "[email protected]^0.2.0"
    "pluginsConfig": {
        "theme-default": {
            "showLevel": true
        "disqus": {
            "shortName": "PFinal"
        "prism": {
            "css": [
        "github": {
            "url": ""
        "github-buttons": {
            "repo": "pfinal/book",
            "types": [
            "size": "small"
        "include-codeblock": {
            "template": "ace",
            "unindent": true,
            "edit": true
        "sharing": {
           "douban": false,
           "hatenaBookmark": false,
           "instapaper": false,
           "line": false,
           "linkedin": false,
           "messenger": false,
           "pocket": false,
           "qq": true,
           "qzone": true,
           "stumbleupon": false,
           "twitter": false,
           "viber": false,
           "vk": false,
           "weibo": true,
           "whatsapp": false,
           "all": [
               "douban", "twitter", "line","facebook"
        "tbfed-pagefooter": {
            "copyright": "Copyright © <a href=''></a> 2018",
            "modify_ The document was revised on,
            "modify_format": "YYYY-MM-DD HH:mm:ss"
        "3-ba": {
            "token": "ff100361cdce95dd4c8fb96b4009f7bc"
        "donate": {
            "wechat": "",
            "alipay": "",
            "title": "",
            "Button": "reward",
            "AlipayText": "Alipay reward".
            "Wechattext": "wechat reward"
        "simple-page-toc": {
            "maxDepth": 3,
            "skipFirstH1": true
        "edit-link": {
            "base": "",
            "label": "Edit This Page"
        "sitemap-general": {
            "prefix": ""
        "anchor-navigation-ex": {
            "isRewritePageTitle": false,
            "tocLevel1Icon": "fa fa-hand-o-right",
            "tocLevel2Icon": "fa fa-hand-o-right",
            "tocLevel3Icon": "fa fa-hand-o-right"
        "sectionx": {
            "tag": "b"
        "favicon": {
            "shortcut": "favicon.ico",
            "bookmark": "favicon.ico"
        "terminal": {
            "copyButtons": true,
            "fade": false,
            "style": "flat"
        "rss": {
            "Title": "pfinal community,",
            "Description": "Introduction to pfinal community,",
            "Author": "Nancheng",
            "categories": [

This article is automatically published by artipub, a multi article publishing platform