Routing
Learn how Docgo maps files, locales, versions, and content-relative links to clean URLs.
Docgo turns docs files into clean URL routes. Locale and version folders are recognized from config and are omitted from the URL when they match the default locale or default version.
File to route rules
Given this config:
i18n: {
defaultLocale: 'en',
locales: [
{ code: 'en', label: 'English' },
{ code: 'ko', label: 'Korean' },
],
},
versioning: {
defaultVersion: 'latest',
versions: [
{ code: 'latest', label: 'Latest' },
{ code: 'v1', label: 'v1' },
],
}Routes are generated like this:
| Source file | Route |
|---|---|
docs/en/latest/index.mdx | / |
docs/en/latest/guide/start.mdx | /guide/start |
docs/ko/latest/index.mdx | /ko |
docs/ko/latest/guide/start.mdx | /ko/guide/start |
docs/en/v1/index.mdx | /v1 |
docs/en/v1/guide/start.mdx | /v1/guide/start |
docs/ko/v1/guide/start.mdx | /ko/v1/guide/start |
index.mdx collapses to its parent route.
Content-relative links
Config links in nav, sidebar, and footer links are written as content
paths, without locale or version prefixes:
nav: [{ text: 'Guide', link: '/guide/getting-started' }];Docgo resolves that link for the current page context:
| Current context | Resolved link |
|---|---|
en + latest | /guide/getting-started |
ko + latest | /ko/guide/getting-started |
en + v1 | /v1/guide/getting-started |
ko + v1 | /ko/v1/guide/getting-started |
This lets one config drive every locale and version.
External links
Absolute URLs, protocol-relative URLs, mailto:, tel:, and hash links are
treated as external or special links and are not prefixed.
nav: [
{ text: 'GitHub', link: 'https://github.com/kyechan99/docgo' },
{ text: 'Contact', link: 'mailto:docs@example.com' },
];Base URL
Use baseUrl when hosting under a sub-path.
export default defineConfig({
baseUrl: '/docs/',
});Docgo prefixes generated asset and internal navigation URLs with /docs/ so
the site works under the deployed path. Same-page heading links remain
fragment-only links like #section.
Locale and version switching
The switchers try to keep the reader on the same content page. If the target locale or version does not have the same page, Docgo falls back to that group's index page when possible.
