2017-09-12 07:13:26 +00:00
|
|
|
+++
|
|
|
|
title = "CLI usage"
|
2017-09-27 14:37:17 +00:00
|
|
|
weight = 2
|
2017-09-12 07:13:26 +00:00
|
|
|
+++
|
|
|
|
|
2017-09-27 14:37:17 +00:00
|
|
|
Gutenberg only has 3 commands: init, build and serve.
|
|
|
|
|
|
|
|
You can view the help of the whole program by running `gutenberg --help` and
|
|
|
|
the command help by running `gutenberg <cmd> --help`.
|
|
|
|
|
|
|
|
## init
|
|
|
|
|
|
|
|
Creates the directory structure used by Gutenberg at the given directory.
|
|
|
|
|
|
|
|
```bash
|
2018-03-16 18:11:08 +00:00
|
|
|
$ gutenberg init my_site
|
2017-09-27 14:37:17 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
will create a new folder named `my_site` and the files/folders needed by
|
|
|
|
Gutenberg.
|
|
|
|
|
|
|
|
## build
|
|
|
|
|
|
|
|
This will build the whole site in the `public` directory.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ gutenberg build
|
|
|
|
```
|
|
|
|
|
2017-10-05 01:56:13 +00:00
|
|
|
You can override the config `base_url` by passing a new URL to the `base-url` flag.
|
|
|
|
|
|
|
|
```bash
|
2017-10-19 11:48:50 +00:00
|
|
|
$ gutenberg build --base-url $DEPLOY_URL
|
2017-10-05 01:56:13 +00:00
|
|
|
```
|
|
|
|
|
2017-10-19 11:48:50 +00:00
|
|
|
This is useful for example when you want to deploy previews of a site to a dynamic URL, such as Netlify
|
|
|
|
deploy previews.
|
|
|
|
|
2017-12-29 18:25:06 +00:00
|
|
|
+You can override the default output directory 'public' by passing a other value to the `output-dir` flag.
|
2018-03-16 18:11:08 +00:00
|
|
|
|
2017-12-29 18:25:06 +00:00
|
|
|
```bash
|
|
|
|
$ gutenberg build --output-dir $DOCUMENT_ROOT
|
|
|
|
```
|
|
|
|
|
2018-03-16 18:11:08 +00:00
|
|
|
You can also point to another config file than `config.toml` like so - the position of the `config` option is important:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ gutenberg --config config.staging.toml build
|
|
|
|
```
|
|
|
|
|
2017-09-27 14:37:17 +00:00
|
|
|
## serve
|
|
|
|
|
|
|
|
This will build and serve the site using a local server. You can also specify
|
|
|
|
the interface/port combination to use if you want something different than the default (`127.0.0.1:1111`).
|
|
|
|
|
2018-02-02 16:34:24 +00:00
|
|
|
You can also specify different addresses for the interface and base_url using `-u`/`--base-url`, for example
|
|
|
|
if you are running Gutenberg in a Docker container.
|
2018-02-02 16:18:07 +00:00
|
|
|
|
2017-09-27 14:37:17 +00:00
|
|
|
```bash
|
|
|
|
$ gutenberg serve
|
|
|
|
$ gutenberg serve --port 2000
|
|
|
|
$ gutenberg serve --interface 0.0.0.0
|
|
|
|
$ gutenberg serve --interface 0.0.0.0 --port 2000
|
2018-02-02 16:18:07 +00:00
|
|
|
$ gutenberg serve --interface 0.0.0.0 --base-url 127.0.0.1
|
2017-12-29 18:25:06 +00:00
|
|
|
$ gutenberg serve --interface 0.0.0.0 --port 2000 --output-dir www/public
|
2017-09-27 14:37:17 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
The serve command will watch all your content and will provide live reload, without
|
|
|
|
hard refresh if possible.
|
2017-10-03 15:21:18 +00:00
|
|
|
|
2017-10-19 11:48:50 +00:00
|
|
|
Gutenberg does a best-effort to live reload but some changes cannot be handled automatically. If you
|
|
|
|
fail to see your change, you will need to restart `gutenberg serve`.
|
2018-03-16 18:11:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
You can also point to another config file than `config.toml` like so - the position of the `config` option is important:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ gutenberg --config config.staging.toml serve
|
|
|
|
```
|