|
1 | 1 | --- |
2 | 2 | title: "Local Development" |
3 | | -description: "Preview changes locally to update your docs" |
| 3 | +description: "Step-by-step guide to preview and test your documentation locally" |
4 | 4 | --- |
5 | 5 |
|
6 | | -<Info> |
7 | | - **Prerequisite**: Please install Node.js (version 19 or higher) before proceeding. |
8 | | -</Info> |
| 6 | +<Note> |
| 7 | + Before you begin, make sure you have Node.js version 19 or higher installed on your computer. You can check your Node.js version by running `node --version` in your terminal. |
| 8 | +</Note> |
9 | 9 |
|
10 | | -**Step 1**: Install the Mintlify CLI: |
| 10 | +## Setting Up Your Environment |
11 | 11 |
|
12 | | -<CodeGroup> |
| 12 | +### Installing the CLI Tool |
| 13 | + |
| 14 | +First, you'll need to install the Mintlify command-line interface (CLI). Choose one of these commands based on your package manager: |
13 | 15 |
|
| 16 | +<CodeGroup> |
14 | 17 | ```bash npm |
15 | 18 | npm i -g mintlify |
16 | 19 | ``` |
17 | 20 |
|
18 | | - |
19 | 21 | ```bash yarn |
20 | 22 | yarn global add mintlify |
21 | 23 | ``` |
22 | 24 |
|
23 | | - |
24 | 25 | ```bash pnpm |
25 | 26 | pnpm add -g mintlify |
26 | 27 | ``` |
27 | | - |
28 | 28 | </CodeGroup> |
29 | 29 |
|
30 | | -**Step 2**: Navigate to the docs directory (where the `docs.json` file is located) and execute the following command: |
| 30 | +### Running the Development Server |
31 | 31 |
|
32 | | -```bash |
33 | | -mintlify dev |
34 | | -``` |
| 32 | +Once installed, follow these steps: |
35 | 33 |
|
36 | | -Alternatively, if you do not want to install the CLI globally you can use a run script available: |
| 34 | +<Steps> |
| 35 | + <Step title="Navigate to Your Docs"> |
| 36 | + Open your terminal and go to your documentation directory (where your `docs.json` file is located). |
| 37 | + </Step> |
| 38 | + |
| 39 | + <Step title="Start the Preview"> |
| 40 | + Run this command to start your local development server: |
| 41 | + ```bash |
| 42 | + mintlify dev |
| 43 | + ``` |
| 44 | + </Step> |
37 | 45 |
|
38 | | -<CodeGroup> |
| 46 | + <Step title="View Your Docs"> |
| 47 | + Open your browser and visit `http://localhost:3000` to see your documentation. |
| 48 | + </Step> |
| 49 | +</Steps> |
39 | 50 |
|
40 | | -```bash npm |
41 | | -npx mintlify dev |
42 | | -``` |
| 51 | +<Tip> |
| 52 | + Don't want to install the CLI globally? You can use these run commands instead: |
43 | 53 |
|
| 54 | + <CodeGroup> |
| 55 | + ```bash npm |
| 56 | + npx mintlify dev |
| 57 | + ``` |
44 | 58 |
|
45 | | -```bash yarn |
46 | | -yarn dlx mintlify dev |
47 | | -``` |
48 | | - |
49 | | - |
50 | | -```bash pnpm |
51 | | -pnpm dlx mintlify dev |
52 | | -``` |
| 59 | + ```bash yarn |
| 60 | + yarn dlx mintlify dev |
| 61 | + ``` |
53 | 62 |
|
54 | | -</CodeGroup> |
55 | | - |
56 | | -<Warning> |
57 | | - Yarn's "dlx" run script requires yarn version \>2. See [here](https://yarnpkg.com/cli/dlx) for more information. |
58 | | -</Warning> |
| 63 | + ```bash pnpm |
| 64 | + pnpm dlx mintlify dev |
| 65 | + ``` |
| 66 | + </CodeGroup> |
| 67 | +</Tip> |
59 | 68 |
|
60 | | -A local preview of your documentation will be available at `http://localhost:3000`. |
| 69 | +## Common Tasks |
61 | 70 |
|
62 | | -### Custom Ports |
| 71 | +### Using a Different Port |
63 | 72 |
|
64 | | -By default, Mintlify uses port 3000. You can customize the port using the `--port` flag. To run Mintlify on port 3333, for instance, use this command: |
| 73 | +Need to run on a different port? Use the `--port` flag: |
65 | 74 |
|
66 | 75 | ```bash |
67 | 76 | mintlify dev --port 3333 |
68 | 77 | ``` |
69 | 78 |
|
70 | | -If you attempt to run on a port that's already in use, it will use the next available port: |
| 79 | +<Info> |
| 80 | + If the port you specify is already in use, Mintlify will automatically try the next available port. |
| 81 | +</Info> |
| 82 | + |
| 83 | +### Checking for Broken Links |
| 84 | + |
| 85 | +Keep your documentation reliable by checking for broken links: |
71 | 86 |
|
72 | | -```md |
73 | | -Port 3000 is already in use. Trying 3001 instead. |
| 87 | +```bash |
| 88 | +mintlify broken-links |
74 | 89 | ``` |
75 | 90 |
|
76 | | -## Versions |
| 91 | +### Updating Your CLI Version |
77 | 92 |
|
78 | | -Please note that each CLI release is associated with a specific version of Mintlify. If your local website doesn't align with the production version, please update the CLI: |
| 93 | +To ensure you're using the latest features, regularly update your CLI: |
79 | 94 |
|
80 | 95 | <CodeGroup> |
81 | | - |
82 | 96 | ```bash npm |
83 | 97 | npm i -g mintlify@latest |
84 | 98 | ``` |
85 | 99 |
|
86 | | - |
87 | 100 | ```bash yarn |
88 | 101 | yarn global upgrade mintlify |
89 | 102 | ``` |
90 | 103 |
|
91 | | - |
92 | 104 | ```bash pnpm |
93 | 105 | pnpm up --global mintlify |
94 | 106 | ``` |
95 | | - |
96 | 107 | </CodeGroup> |
97 | 108 |
|
98 | | -## Validating Links |
| 109 | +## Best Practices |
99 | 110 |
|
100 | | -The CLI can assist with validating reference links made in your documentation. To identify any broken links, use the following command: |
| 111 | +### Code Formatting |
| 112 | +For the best writing experience, we recommend: |
101 | 113 |
|
102 | | -```bash |
103 | | -mintlify broken-links |
104 | | -``` |
| 114 | +<CardGroup cols={2}> |
| 115 | + <Card title="MDX Extension" icon="brackets-curly"> |
| 116 | + Install the [MDX VSCode extension](https://marketplace.visualstudio.com/items?itemName=unifiedjs.vscode-mdx) for proper syntax highlighting |
| 117 | + </Card> |
| 118 | + <Card title="Prettier" icon="wand-magic-sparkles"> |
| 119 | + Use [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) to automatically format your documentation |
| 120 | + </Card> |
| 121 | +</CardGroup> |
| 122 | + |
| 123 | +## Troubleshooting Guide |
| 124 | + |
| 125 | +<AccordionGroup> |
| 126 | + <Accordion title="Development server won't start" icon="circle-exclamation"> |
| 127 | + Try these steps in order: |
| 128 | + 1. Check your Node.js version (`node --version`) |
| 129 | + 2. Delete the `~/.mintlify` folder |
| 130 | + 3. Reinstall the CLI: `npm remove -g mintlify && npm install -g mintlify` |
| 131 | + </Accordion> |
| 132 | + |
| 133 | + <Accordion title='Error: "sharp" module not loading' icon="wrench"> |
| 134 | + This usually means you need to update Node.js: |
| 135 | + 1. Remove Mintlify: `npm remove -g mintlify` |
| 136 | + 2. Update to Node.js v19 or higher |
| 137 | + 3. Reinstall: `npm install -g mintlify` |
| 138 | + </Accordion> |
| 139 | + |
| 140 | + <Accordion title="Changes not showing up" icon="rotate"> |
| 141 | + Try these solutions: |
| 142 | + 1. Clear your browser cache |
| 143 | + 2. Restart the development server |
| 144 | + 3. Check for syntax errors in your MDX files |
| 145 | + </Accordion> |
| 146 | +</AccordionGroup> |
105 | 147 |
|
106 | | -## Deployment |
| 148 | +## Deployment Status |
107 | 149 |
|
108 | | -If the deployment is successful, you should see the following: |
| 150 | +When your deployment succeeds, you'll see green checkmarks in your GitHub status: |
109 | 151 |
|
110 | 152 | <Frame> |
111 | 153 | <img |
112 | 154 | className="rounded-md" |
113 | 155 | src="https://mintlify.s3-us-west-1.amazonaws.com/mintlify/images/checks-passed.png" |
| 156 | + alt="Successful deployment status showing green checkmarks" |
114 | 157 | /> |
115 | | -</Frame> |
116 | | - |
117 | | -## Code Formatting |
118 | | - |
119 | | -We suggest using extensions on your IDE to recognize and format MDX. If you're a VSCode user, consider the [MDX VSCode extension](https://marketplace.visualstudio.com/items?itemName=unifiedjs.vscode-mdx) for syntax highlighting, and [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) for code formatting. |
120 | | - |
121 | | -## Troubleshooting |
122 | | - |
123 | | -<AccordionGroup> |
124 | | - <Accordion title='Error: Could not load the "sharp" module using the darwin-arm64 runtime'> |
125 | | - This may be due to an outdated version of node. Try the following: |
126 | | - |
127 | | - 1. Remove the currently-installed version of mintlify: `npm remove -g mintlify` |
128 | | - 2. Upgrade to Node v19 or higher. |
129 | | - 3. Reinstall mintlify: `npm install -g mintlify` |
130 | | - </Accordion> |
131 | | - <Accordion title="Issue: Encountering an unknown error"> |
132 | | - Solution: Go to the root of your device and delete the ~/.mintlify folder. Afterwards, run `mintlify dev` again. |
133 | | - </Accordion> |
134 | | -</AccordionGroup> |
| 158 | +</Frame> |
0 commit comments