Simple use of gitbook

Time:2021-1-25

Basic use

install

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

initialization

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

structure

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
├── README.md
├── SUMMARY.md
├── chapter-1/
|   ├── README.md
|   └── something.md
└── chapter-2/
    ├── README.md
    └── something.md

Document description:

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

catalog

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.

Example:

# Summary

* [Part I](part1/README.md)
    * [Writing is nice](part1/writing.md)
    * [GitBook is nice](part1/gitbook.md)
* [Part II](part2/README.md)
    * [We love feedback](part2/feedback_please.md)
    * [Better tools for authors](part2/better_tools.md)

part

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

# Summary

### Part I

* [Writing is nice](part1/writing.md)
* [GitBook is nice](part1/gitbook.md)

### Part II

* [We love feedback](part2/feedback_please.md)
* [Better tools for authors](part2/better_tools.md)

----

* [Last part without title](part3/title.md)

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",
    "output.name": "site",
    "language": "zh-hans",
    "gitbook": "3.2.3",
    "root": ".",
    "structure": {
        "readme": "README.md"
    },
    "links": {
        "sidebar": {
            "Pfinal community":“ http://www.pfinalClub.com "
        }
    },
    "plugins": [
        "-lunr",
        "-search",
        "-highlight",
        "-livereload",
        "[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",
        "-sharing",
        "[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": [
                "prism-themes/themes/prism-base16-ateliersulphurpool.light.css"
            ]
        },
        "github": {
            "url": "https://github.com/pfinal/book"
        },
        "github-buttons": {
            "repo": "pfinal/book",
            "types": [
                "star"
            ],
            "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='http://pfinalClub.com'>pfinalClub.com</a> 2018",
            "modify_ The document was revised on,
            "modify_format": "YYYY-MM-DD HH:mm:ss"
        },
        "3-ba": {
            "token": "ff100361cdce95dd4c8fb96b4009f7bc"
        },
        "donate": {
            "wechat": "https://imgs.developpaper.com/imgs/wechat.JPG",
            "alipay": "https://imgs.developpaper.com/imgs/alipay.JPG",
            "title": "",
            "Button": "reward",
            "AlipayText": "Alipay reward".
            "Wechattext": "wechat reward"
        },
        "simple-page-toc": {
            "maxDepth": 3,
            "skipFirstH1": true
        },
        "edit-link": {
            "base": "https://github.com/pfinal/book/edit/master",
            "label": "Edit This Page"
        },
        "sitemap-general": {
            "prefix": "http://gitbook.pfinal.com"
        },
        "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": [
                "gitbook"
            ]
        }
    }
}

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