You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cli-usage.md 3.3KB

7 years ago
7 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. +++
  2. title = "CLI usage"
  3. weight = 2
  4. +++
  5. Zola only has 3 commands: init, build and serve.
  6. You can view the help of the whole program by running `zola --help` and
  7. the command help by running `zola <cmd> --help`.
  8. ## init
  9. Creates the directory structure used by Zola at the given directory.
  10. ```bash
  11. $ zola init my_site
  12. ```
  13. will create a new folder named `my_site` and the files/folders needed by
  14. zola.
  15. ## build
  16. This will build the whole site in the `public` directory after deleting it.
  17. ```bash
  18. $ zola build
  19. ```
  20. You can override the config `base_url` by passing a new URL to the `base-url` flag.
  21. ```bash
  22. $ zola build --base-url $DEPLOY_URL
  23. ```
  24. This is useful for example when you want to deploy previews of a site to a dynamic URL, such as Netlify
  25. deploy previews.
  26. You can override the default `base_path` by passing a new directory to the `base-path` flag. If no `base-path` flag
  27. is provided, zola defaults to your current working directory. This is useful if your zola project is located in
  28. a different directory from where you're executing zola from.
  29. ```bash
  30. $ zola build --base-path /path/to/zola/site
  31. ```
  32. You can override the default output directory 'public' by passing a other value to the `output-dir` flag.
  33. ```bash
  34. $ zola build --output-dir $DOCUMENT_ROOT
  35. ```
  36. You can also point to another config file than `config.toml` like so - the position of the `config` option is important:
  37. ```bash
  38. $ zola --config config.staging.toml build
  39. ```
  40. ## serve
  41. This will build and serve the site using a local server. You can also specify
  42. the interface/port combination to use if you want something different than the default (`127.0.0.1:1111`).
  43. You can also specify different addresses for the interface and base_url using `-u`/`--base-url`, for example
  44. if you are running zola in a Docker container.
  45. In the event you don't want zola to run a local webserver, you can use the `--watch-only` flag.
  46. Before starting, it will delete the public directory to ensure it starts from a clean slate.
  47. ```bash
  48. $ zola serve
  49. $ zola serve --port 2000
  50. $ zola serve --interface 0.0.0.0
  51. $ zola serve --interface 0.0.0.0 --port 2000
  52. $ zola serve --interface 0.0.0.0 --base-url 127.0.0.1
  53. $ zola serve --interface 0.0.0.0 --port 2000 --output-dir www/public
  54. $ zola serve --interface 0.0.0.0 --port 2000 --base-path mysite/ --output-dir mysite/www/public
  55. $ zola serve --watch-only
  56. ```
  57. The serve command will watch all your content and will provide live reload, without
  58. hard refresh if possible.
  59. Zola does a best-effort to live reload but some changes cannot be handled automatically. If you
  60. fail to see your change or get a weird error, try to restart `zola serve`.
  61. You can also point to another config file than `config.toml` like so - the position of the `config` option is important:
  62. ```bash
  63. $ zola --config config.staging.toml serve
  64. ```
  65. ## Colored output
  66. Any of the three commands will emit colored output if your terminal supports it.
  67. *Note*: coloring is automatically disabled when the output is redirected to a pipe or a file (ie. when the standard output is not a TTY).
  68. You can disable this behavior by exporting one of the two following environment variables:
  69. - `NO_COLOR` (the value does not matter)
  70. - `CLICOLOR=0`
  71. Should you want to force the use of colors, you can set the following environment variable:
  72. - `CLICOLOR_FORCE=1`