Configuring Content Systems
A content system is an independent documentation collection with its own folder, routes, and navigation. You can have multiple collections running on the same site.
What is a Content System?
A content system defines:
- A folder where your markdown files live
- A URL route where the docs appear
- A default page redirect
System 1: "docs"
βββ Folder: content/docs/
βββ Route: /docs/*
βββ Files: All markdown in content/docs/
System 2: "api"
βββ Folder: content/api/
βββ Route: /api/*
βββ Files: All markdown in content/api/
Configuration
Content systems are defined in data/config.ts:
export const CONTENT: ContentConfig = {
systems: [
{
id: "docs", // Unique ID
dir: "content/docs", // Folder path
defaultDocRedirect: "/docs/intro", // Default page
route: "/docs", // URL prefix
},
{
id: "api",
dir: "content/api",
defaultDocRedirect: "/api/overview",
route: "/api",
},
],
};
Required Properties
id: Unique identifier
- Used to reference this system in navigation config
- Lowercase, alphanumeric, hyphens
- Example:
"docs","api","user-guide"
dir: Content folder path
- Relative to project root
- Must start with
content/ - Example:
"content/docs","content/api"
defaultDocRedirect: Where to send users visiting the base route
- When user visits
/docs/, redirect to this page - Should match a real page slug
- Example:
"/docs/getting-started/introduction"
route: URL prefix for this collection
- Base path for all pages in this collection
- Must start with
/ - Example:
"/docs","/api","/guides"
Single System Example
export const CONTENT: ContentConfig = {
systems: [
{
id: "docs",
dir: "content/docs",
defaultDocRedirect: "/docs/getting-started/introduction",
route: "/docs",
},
],
};
Multiple Systems Example
export const CONTENT: ContentConfig = {
systems: [
{
id: "docs",
dir: "content/docs",
defaultDocRedirect: "/docs/getting-started",
route: "/docs",
},
{
id: "api",
dir: "content/api",
defaultDocRedirect: "/api/v1/overview",
route: "/api",
},
{
id: "guides",
dir: "content/guides",
defaultDocRedirect: "/guides/tutorials/first-project",
route: "/guides",
},
],
};
Navigation Configuration for Each System
Each system needs navigation configuration:
export const SIDEBAR_NAVIGATION: SidebarNavigation = {
docs: {
defaultTab: { label: "Documentation", icon: "π" },
groups: [
/* docs navigation */
],
},
api: {
defaultTab: { label: "API Reference", icon: "π‘" },
groups: [
/* api navigation */
],
},
guides: {
defaultTab: { label: "Tutorials", icon: "π" },
groups: [
/* guides navigation */
],
},
};
File Structure for Multiple Systems
content/
βββ docs/ <- System 1: "docs"
β βββ getting-started/
β βββ features/
β βββ help/
βββ api/ <- System 2: "api"
β βββ authentication/
β βββ endpoints/
β βββ webhooks/
βββ guides/ <- System 3: "guides"
βββ tutorials/
βββ patterns/
βββ examples/
URL Mapping
With this configuration:
systems: [
{ id: "docs", dir: "content/docs", route: "/docs" },
{ id: "api", dir: "content/api", route: "/api" },
];
Files map to URLs:
| File | Route | URL |
|---|---|---|
| content/docs/getting-started/intro.md | /docs | /docs/getting-started/intro |
| content/docs/features/tabs.md | /docs | /docs/features/tabs |
| content/api/endpoints/users.md | /api | /api/endpoints/users |
| content/api/webhooks/events.md | /api | /api/webhooks/events |
Default Redirect
When users visit just the base route, theyβre redirected:
User visits: https://mydocs.com/docs/
Redirects to: https://mydocs.com/docs/getting-started/introduction
Choose a page that makes sense as a landing page.
Systems with Different Configurations
Each system can have completely different navigation structures:
export const SIDEBAR_NAVIGATION = {
// System 1: Simple auto-generated
docs: {
defaultTab: { label: "Learn" },
groups: [{ id: "guides", label: "Guides", autoGenerated: true }],
},
// System 2: Complex with tabs and nesting
api: {
defaultTab: { label: "v2" },
groups: [
{ id: "v1", label: "v1", tab: true },
{
id: "v2",
label: "v2",
tab: true,
groups: [
{ id: "auth", label: "Auth", autoGenerated: true },
{ id: "endpoints", label: "Endpoints", autoGenerated: true },
],
},
],
},
};
Adding a New System
1. Create the Folder
mkdir -p content/new-collection
2. Add Markdown Files
echo "---\ntitle: 'First Page'\n---\n# First Page" > content/new-collection/first.md
3. Register in CONTENT
export const CONTENT: ContentConfig = {
systems: [
// existing systems...
{
id: "new-collection",
dir: "content/new-collection",
defaultDocRedirect: "/new-collection/first",
route: "/new-collection",
},
],
};
4. Configure Navigation
export const SIDEBAR_NAVIGATION: SidebarNavigation = {
// existing configs...
"new-collection": {
defaultTab: { label: "New Collection", icon: "π" },
groups: [{ id: "pages", label: "Pages", autoGenerated: true }],
},
};
5. Visit the Site
Navigate to http://localhost:4321/new-collection/first and itβs live!
Next Steps
Learn about: