| 1 |
# The init command |
| 2 |
|
| 3 |
There is some minimal boilerplate that is the same for every new book. It's for |
| 4 |
this purpose that mdBook includes an `init` command. |
| 5 |
|
| 6 |
The `init` command is used like this: |
| 7 |
|
| 8 |
```bash |
| 9 |
mdbook init |
| 10 |
``` |
| 11 |
|
| 12 |
When using the `init` command for the first time, a couple of files will be set |
| 13 |
up for you: |
| 14 |
```bash |
| 15 |
book-test/ |
| 16 |
├── book |
| 17 |
└── src |
| 18 |
├── chapter_1.md |
| 19 |
└── SUMMARY.md |
| 20 |
``` |
| 21 |
|
| 22 |
- The `src` directory is where you write your book in markdown. It contains all |
| 23 |
the source files, configuration files, etc. |
| 24 |
|
| 25 |
- The `book` directory is where your book is rendered. All the output is ready |
| 26 |
to be uploaded to a server to be seen by your audience. |
| 27 |
|
| 28 |
- The `SUMMARY.md` is the skeleton of your |
| 29 |
book, and is discussed in more detail [in another |
| 30 |
chapter](../format/summary.md). |
| 31 |
|
| 32 |
#### Tip: Generate chapters from SUMMARY.md |
| 33 |
|
| 34 |
When a `SUMMARY.md` file already exists, the `init` command will first parse it |
| 35 |
and generate the missing files according to the paths used in the `SUMMARY.md`. |
| 36 |
This allows you to think and create the whole structure of your book and then |
| 37 |
let mdBook generate it for you. |
| 38 |
|
| 39 |
#### Specify a directory |
| 40 |
|
| 41 |
The `init` command can take a directory as an argument to use as the book's root |
| 42 |
instead of the current working directory. |
| 43 |
|
| 44 |
```bash |
| 45 |
mdbook init path/to/book |
| 46 |
``` |
| 47 |
|
| 48 |
#### `--theme` |
| 49 |
|
| 50 |
When you use the `--theme` flag, the default theme will be copied into a |
| 51 |
directory called `theme` in your source directory so that you can modify it. |
| 52 |
|
| 53 |
The theme is selectively overwritten, this means that if you don't want to |
| 54 |
overwrite a specific file, just delete it and the default file will be used. |
| 55 |
|
| 56 |
#### `--title` |
| 57 |
|
| 58 |
Specify a title for the book. If not supplied, an interactive prompt will ask for |
| 59 |
a title. |
| 60 |
|
| 61 |
```bash |
| 62 |
mdbook init --title="my amazing book" |
| 63 |
``` |
| 64 |
|
| 65 |
#### `--ignore` |
| 66 |
|
| 67 |
Create a `.gitignore` file configured to ignore the `book` directory created when [building] a book. |
| 68 |
If not supplied, an interactive prompt will ask whether it should be created. |
| 69 |
|
| 70 |
```bash |
| 71 |
mdbook init --ignore=none |
| 72 |
``` |
| 73 |
|
| 74 |
```bash |
| 75 |
mdbook init --ignore=git |
| 76 |
``` |
| 77 |
|
| 78 |
[building]: build.md |
| 79 |
|
| 80 |
#### `--force` |
| 81 |
|
| 82 |
Skip the prompts to create a `.gitignore` and for the title for the book. |