2015-07-30 17:59:08 +08:00
|
|
|
# The init command
|
2018-08-03 05:52:54 +08:00
|
|
|
|
|
|
|
There is some minimal boilerplate that is the same for every new book. It's for this purpose
|
|
|
|
that mdBook includes an `init` command.
|
2015-07-30 17:59:08 +08:00
|
|
|
|
2015-09-25 04:19:14 +08:00
|
|
|
The `init` command is used like this:
|
2015-07-30 17:59:08 +08:00
|
|
|
|
2015-12-30 06:59:08 +08:00
|
|
|
```bash
|
2015-07-30 17:59:08 +08:00
|
|
|
mdbook init
|
|
|
|
```
|
|
|
|
|
2015-12-30 22:04:24 +08:00
|
|
|
When using the `init` command for the first time, a couple of files will be set up for you:
|
|
|
|
```bash
|
2015-07-30 17:59:08 +08:00
|
|
|
book-test/
|
|
|
|
├── book
|
|
|
|
└── src
|
|
|
|
├── chapter_1.md
|
|
|
|
└── SUMMARY.md
|
|
|
|
```
|
|
|
|
|
2015-12-30 22:04:24 +08:00
|
|
|
- The `src` directory is were you write your book in markdown. It contains all the source files,
|
2015-07-30 17:59:08 +08:00
|
|
|
configuration files, etc.
|
|
|
|
|
2015-12-30 22:04:24 +08:00
|
|
|
- The `book` directory is where your book is rendered. All the output is ready to be uploaded
|
|
|
|
to a server to be seen by your audience.
|
2015-09-25 04:19:14 +08:00
|
|
|
|
2018-08-03 05:52:54 +08:00
|
|
|
- The `SUMMARY.md` file is the most important file, it's the skeleton of your book and is
|
|
|
|
discussed in more detail [in another chapter](../format/summary.md)
|
|
|
|
|
|
|
|
#### Tip: Generate chapters from SUMMARY.md
|
2015-07-30 17:59:08 +08:00
|
|
|
|
2018-08-03 05:52:54 +08:00
|
|
|
When a `SUMMARY.md` file already exists, the `init` command will first parse it and generate the
|
|
|
|
missing files according to the paths used in the `SUMMARY.md`. This allows you to think and create
|
|
|
|
the whole structure of your book and then let mdBook generate it for you.
|
2015-07-30 17:59:08 +08:00
|
|
|
|
|
|
|
#### Specify a directory
|
|
|
|
|
2018-08-03 05:52:54 +08:00
|
|
|
The `init` command can take a directory as an argument to use as the book's
|
|
|
|
root instead of the current working directory.
|
2015-07-30 17:59:08 +08:00
|
|
|
|
2015-12-30 06:59:08 +08:00
|
|
|
```bash
|
2015-07-30 17:59:08 +08:00
|
|
|
mdbook init path/to/book
|
|
|
|
```
|
|
|
|
|
2018-08-03 05:52:54 +08:00
|
|
|
#### --theme
|
2015-08-11 23:15:54 +08:00
|
|
|
|
2018-08-03 05:52:54 +08:00
|
|
|
When you use the `--theme` flag, the default theme will be copied into a directory
|
2015-08-11 23:15:54 +08:00
|
|
|
called `theme` in your source directory so that you can modify it.
|
|
|
|
|
|
|
|
The theme is selectively overwritten, this means that if you don't want to overwrite a
|
|
|
|
specific file, just delete it and the default file will be used.
|