|
| 1 | +# Quick start |
| 2 | + |
| 3 | +It is recommended to install `docsify-cli` globally, which helps initializing and previewing the website locally. |
| 4 | + |
| 5 | +```bash |
| 6 | +npm i docsify-cli -g |
| 7 | +``` |
| 8 | + |
| 9 | +## Initialize |
| 10 | + |
| 11 | +If you want to write the documentation in the `./docs` subdirectory, you can use the `init` command. |
| 12 | + |
| 13 | +```bash |
| 14 | +docsify init ./docs |
| 15 | +``` |
| 16 | + |
| 17 | +## Writing content |
| 18 | + |
| 19 | +After the `init` is complete, you can see the file list in the `./docs` subdirectory. |
| 20 | + |
| 21 | +* `index.html` as the entry file |
| 22 | +* `README.md` as the home page |
| 23 | +* `.nojekyll` prevents GitHub Pages from ignoring files that begin with an underscore |
| 24 | + |
| 25 | +You can easily update the documentation in `./docs/README.md`, of course you can add [more pages](more-pages.md). |
| 26 | + |
| 27 | +## Preview your site |
| 28 | + |
| 29 | +Run the local server with `docsify serve`. You can preview your site in your browser on `http://localhost:3000`. |
| 30 | + |
| 31 | +```bash |
| 32 | +docsify serve docs |
| 33 | +``` |
| 34 | + |
| 35 | +?> For more use cases of `docsify-cli`, head over to the [docsify-cli documentation](https://github.com/docsifyjs/docsify-cli). |
| 36 | + |
| 37 | +## Manual initialization |
| 38 | + |
| 39 | +If you don't like `npm` or have trouble installing the tool, you can manually create `index.html`: |
| 40 | + |
| 41 | +```html |
| 42 | +<!-- index.html --> |
| 43 | + |
| 44 | +<!DOCTYPE html> |
| 45 | +<html> |
| 46 | +<head> |
| 47 | + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| 48 | + <meta name="viewport" content="width=device-width,initial-scale=1"> |
| 49 | + <meta charset="UTF-8"> |
| 50 | + <link rel="stylesheet" href="//unpkg.com/docsify/themes/vue.css"> |
| 51 | +</head> |
| 52 | +<body> |
| 53 | + <div id="app"></div> |
| 54 | + <script> |
| 55 | + window.$docsify = { |
| 56 | + //... |
| 57 | + } |
| 58 | + </script> |
| 59 | + <script src="//unpkg.com/docsify/lib/docsify.min.js"></script> |
| 60 | +</body> |
| 61 | +</html> |
| 62 | +``` |
| 63 | + |
| 64 | +If you installed python on your system, you can easily use it to run a static server to preview your site. |
| 65 | + |
| 66 | +```bash |
| 67 | +cd docs && python -m SimpleHTTPServer 3000 |
| 68 | +``` |
| 69 | + |
| 70 | +## Loading dialog |
| 71 | + |
| 72 | +If you want, you can show a loading dialog before docsify starts to render your documentation: |
| 73 | + |
| 74 | +```html |
| 75 | + <!-- index.html --> |
| 76 | + |
| 77 | + <div id="app">Please wait...</div> |
| 78 | +``` |
| 79 | + |
| 80 | +You should set the `data-app` attribute if you changed `el`: |
| 81 | + |
| 82 | +```html |
| 83 | + <!-- index.html --> |
| 84 | + |
| 85 | + <div data-app id="main">Please wait...</div> |
| 86 | + |
| 87 | + <script> |
| 88 | + window.$docsify = { |
| 89 | + el: '#main' |
| 90 | + } |
| 91 | + </script> |
| 92 | +``` |
| 93 | + |
| 94 | +Compare [el configuration](configuration.md#el). |
0 commit comments