Use and application of gitbook book.json Detailed configuration



Installation command: 1

npm install -g gitbook-cli test

After the installation is complete, you can use the following command to check whether the installation is successful.

$ gitbook -V
CLI version: 2.3.2
GitBook version: 3.2.3


  • Initialize gitbook init
    After getting ready for gitbook, let’s go to a directory where you want to write a book and enter the following command.

    $ gitbook init
    warn: no summary file in this book
    info: create
    info: create
    info: initialization is finished

    You can see that he will create And These two documents, Should not be unfamiliar, that is, documentation, rather than In fact, it is the chapter directory of the book, and its default content is as follows

    # Summary
If it has been initialized, it can be started directly

-Start the local service gitbook serve`  
Next, we enter the '$gitbook serve' command, and then enter it in the browser address bar` http://localhost :4000`

-New directory

First, let's look at the gitbook directory structure and related files


Main storage configuration information

  "plugins": [
  "Title": "publishing business logic sorting,",
  "pluginsConfig": {
      "tbfed-pagefooter": {
          "copyright":"Copyright &copy ershouche-FE 2019",
          "modify_ Revision time of the document,
          "modify_format": "YYYY-MM-DD HH:mm:ss"
      "disqus": {
        "shortName": "gitbookuse"

Chapter contents of gitbook

When adding a new directory file, executing gitbook init will automatically create the file under the corresponding directory  

be careful:  

The top-level directory is the first level directory, and the second level directory is indented once. By default, it will be indented into the corresponding first level directory. If you want to create a deeper directory structure, you can create it by indenting under the corresponding subdirectory  

The indentation in this file is the indentation of the document sidebar directory

<img width="200" />

-Building gitbook build  

Executing this command generates a_ Book folder, the contents of which for the generated HTML file

##Configuration book.json

###Configuration description

|Variable | description|
| :-----------: | :----------------------------------------------------------: |
|Root | the path to the root folder containing all book files, except book.json        |
|Structure | specifies the path to the readme file, summary, vocabulary, etc|
|Title | your book title. The default value is extracted from readme. In  In this case, this field is pre filled. |
|Description | the description of your book. The default value is extracted from readme. In  In this case, this field is pre filled. |
|Author | author's name. stay In this case, this field is pre filled. |
|Language | language types of this book - [ISO code]( of_ ISO_ 639-1_ codes) 。 The default value is ` en ~|
|Direction | text reading order. It can be RTL (from right to left) or LTR (from left to right), and the default value depends on the value of language. |
|Gitbook | should use gitbook version, and accept conditions similar to '> = 3.0.0'. |
|Links | add link information to the left navigation bar|
|Plugins | list of plug-ins to load ([official website plug-in list]( )) |
|Configuration of pluginsconfig | plug in|

###Default plug in

-Highlight - syntax highlight plug in
-Search - Search plug in
-Sharing - sharing plug in
-Font settings - font settings plug in
-Livereload - hot load plug in







###Remove default plug-in

在平时开发中比如share给出的都是一些国外的社交网站 对于我们没太大用户 那么我们可以删除默认配置

Add '-' to the plug-in configuration, and execute 'gitbook install' after configuration

plugins: [

The results are as follows  



###Common configuration

####Code duplication

"plugins": [

The results are as follows  


Code copy button

"plugins": [


####Catalog collapse

"plugins": [

The results are as follows  


"plugins": [

It's the same as above. The difference is that the arrow below should be smaller.

The results are as follows  


####Back to the top

"plugins": [

The results are as follows  


#### 高级search

去除默认的searchsearch和lunr,在search结果中,关键字会高亮;自带的 search 插件,关键字不会高亮

"plugins": [






#### share

share当前页面,比默认的 sharing 插件多了一些share方式

"plugins": ["-sharing", "sharing-plus"],
  "pluginsConfig": {
      "sharing": {
           "douban": false,
           "facebook": false,
           "google": true,
           "pocket": false,
           "qq": false,
           "qzone": true,
           "twitter": false,
           "weibo": true,
        "all": [
             "douban", "facebook", "google", "instapaper", "linkedin","twitter", "weibo", 
             "messenger","qq", "qzone","viber","whatsapp"


The results are as follows  


shareThe results are as follows  


####Configure footers

"plugins": [
  "pluginsConfig": {
      "tbfed-pagefooter": {
          "copyright":"Copyright &copy mine 2000-2020",
          "modify_ Revision time of the document,
          "modify_format": "YYYY-MM-DD HH:mm:ss"

The results are as follows