Skip to content

Commit 20f0434

Browse files
authored
Clarify "Generate rewrites" tool to only be used for custom base paths (#1485)
* clarify rewrite methods * add images * copyedits * move note about repository structure * add missing `/docs` from rewrites * update snippet to use `subpath` * consolidate /docs steps * copyedit
1 parent 35e1edf commit 20f0434

File tree

4 files changed

+42
-34
lines changed

4 files changed

+42
-34
lines changed

deploy/vercel.mdx

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,50 @@ The `vercel.json` file configures how your project is built and deployed. It sit
1111

1212
We use the `rewrites` configuration to proxy requests from your main domain to your documentation.
1313

14-
Rewrites map incoming requests to different destinations without changing the URL in the browser. When someone visits `yoursite.com/docs`, Vercel will internally fetch content from `your-subdomain.mintlify.dev/docs` but the user will still see `yoursite.com/docs` in their browser. This is different from redirects, which would send users to a different URL entirely.
14+
Rewrites map incoming requests to different destinations without changing the URL in the browser. When someone visits `yoursite.com/docs`, Vercel internally fetches content from `your-subdomain.mintlify.dev/docs`, but the user still sees `yoursite.com/docs` in their browser. This is different from redirects, which send users to another URL entirely.
1515

1616
You can customize the subpath to any value you prefer, such as `/docs`, `/help`, or `/guides`. Additionally, you can use deeply nested subpaths like `/product/docs`.
1717

18-
## Repository structure
19-
20-
Your documentation files must be organized within your repository to match your chosen subpath structure. For example, if you want your documentation at `yoursite.com/docs`, you would create a `docs/` directory with all of your documentation files.
21-
2218
## Configuration
2319

24-
To host your documentation at a custom subpath using Vercel, add the following configuration to your `vercel.json` file. This example uses `/docs`, but you can replace it with any subpath:
25-
26-
```json
27-
{
28-
"rewrites": [
29-
{
30-
"source": "/docs",
31-
"destination": "https://[subdomain].mintlify.dev/docs"
32-
},
33-
{
34-
"source": "/docs/:match*",
35-
"destination": "https://[subdomain].mintlify.dev/docs/:match*"
36-
}
37-
]
38-
}
39-
```
20+
### Host from `/docs`
21+
22+
1. Navigate to [Custom domain setup](https://dashboard.mintlify.com/settings/deployment/custom-domain) in your dashboard.
23+
2. Click the **Host at `/docs`** toggle to the on position.
24+
<Frame>
25+
<img alt="Screenshot of the Custom domain setup page. The Host at `/docs` toggle is on and highlighted by an orange rectangle." src="/images/subpath/toggle-light.png" className="block dark:hidden" />
26+
<img alt="Screenshot of the Custom domain setup page. The Host at `/docs` toggle is on and highlighted by an orange rectangle." src="/images/subpath/toggle-dark.png" className="hidden dark:block" />
27+
</Frame>
28+
3. Enter your domain.
29+
4. Select **Add domain**.
30+
5. Add the following rewrites to your `vercel.json` file. Replace `[subdomain]` with your subdomain:
31+
32+
```json
33+
{
34+
"rewrites": [
35+
{
36+
"source": "/docs",
37+
"destination": "https://[subdomain].mintlify.dev/docs"
38+
},
39+
{
40+
"source": "/docs/:match*",
41+
"destination": "https://[subdomain].mintlify.dev/docs/:match*"
42+
}
43+
]
44+
}
45+
```
4046

4147
- **`source`**: The path pattern on your domain that triggers the rewrite.
4248
- **`destination`**: Where the request should be proxied to.
4349
- **`:match*`**: A wildcard that captures any path segments after your subpath.
4450

4551
For more information, see [Configuring projects with vercel.json: Rewrites](https://vercel.com/docs/projects/project-configuration#rewrites) in the Vercel documentation.
4652

47-
### Generate rewrites
53+
### Host from custom path
54+
55+
To use a custom subpath (any path other than `/docs`), you must organize your documentation files within your repository to match your subpath structure. For example, if your documentation is hosted at `yoursite.com/help`, your documentation files must be in a `help/` directory.
4856

49-
Enter your subdomain and custom subdirectory to generate the rewrites for your `vercel.json` file.
57+
Use the generator below to create your rewrites configuration. Add the rewrites to your `vercel.json` file.
5058

5159
<VercelJsonGenerator />
5260

images/subpath/toggle-dark.png

48.7 KB
Loading

images/subpath/toggle-light.png

48.1 KB
Loading

snippets/vercel-json-generator.mdx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const VercelJsonGenerator = () => {
22
const [subdomain, setSubdomain] = useState('[SUBDOMAIN]')
3-
const [subdirectory, setSubdirectory] = useState('docs')
3+
const [subpath, setSubpath] = useState('[SUBPATH]')
44

55
const vercelConfig = {
66
rewrites: [
@@ -13,28 +13,28 @@ export const VercelJsonGenerator = () => {
1313
destination: `https://${subdomain}.mintlify.app/_mintlify/api/request`
1414
},
1515
{
16-
source: `/${subdirectory}`,
16+
source: `/${subpath}`,
1717
destination: `https://${subdomain}.mintlify.app`
1818
},
1919
{
20-
source: `/${subdirectory}/llms.txt`,
20+
source: `/${subpath}/llms.txt`,
2121
destination: `https://${subdomain}.mintlify.app/llms.txt`
2222
},
2323
{
24-
source: `/${subdirectory}/llms-full.txt`,
24+
source: `/${subpath}/llms-full.txt`,
2525
destination: `https://${subdomain}.mintlify.app/llms-full.txt`
2626
},
2727
{
28-
source: `/${subdirectory}/sitemap.xml`,
28+
source: `/${subpath}/sitemap.xml`,
2929
destination: `https://${subdomain}.mintlify.app/sitemap.xml`
3030
},
3131
{
32-
source: `/${subdirectory}/robots.txt`,
32+
source: `/${subpath}/robots.txt`,
3333
destination: `https://${subdomain}.mintlify.app/robots.txt`
3434
},
3535
{
36-
source: `/${subdirectory}/:path*`,
37-
destination: `https://${subdomain}.mintlify.app/${subdirectory}/:path*`
36+
source: `/${subpath}/:path*`,
37+
destination: `https://${subdomain}.mintlify.app/${subpath}/:path*`
3838
},
3939
{
4040
source: "/mintlify-assets/:path+",
@@ -71,12 +71,12 @@ export const VercelJsonGenerator = () => {
7171
</div>
7272
<div>
7373
<label className="block text-sm text-zinc-950/70 dark:text-white/70 mb-1">
74-
Subdirectory
74+
Subpath
7575
</label>
7676
<input
7777
type="text"
78-
value={subdirectory}
79-
onChange={(e) => setSubdirectory(e.target.value)}
78+
value={subpath}
79+
onChange={(e) => setSubpath(e.target.value)}
8080
placeholder="docs"
8181
className="w-full p-1 text-sm rounded border dark:border-white/10 bg-transparent"
8282
/>

0 commit comments

Comments
 (0)