Adding Document
Adding New Documentation Pages
Section titled “Adding New Documentation Pages”This guide will walk you through the process of adding new documentation pages to your Dockit site, organizing them properly, and ensuring they appear in the navigation.
File Structure
Section titled “File Structure”All documentation files are located in the src/content/docs/ directory. The structure looks like this:
src/content/docs/├── index.mdx # Homepage├── getting-started/ # Getting started section│ ├── introduction/│ ├── global-settings/│ └── navigation.md├── guides/ # Guides section│ └── example.md├── reference/ # Reference section│ ├── configuration.mdx│ └── example.mdx├── resources/ # Resources section│ ├── community-content.mdx│ ├── plugins.mdx│ ├── showcase.mdx│ └── themes.mdx└── contents/ # Additional content ├── components/ └── editing/Creating a New Page
Section titled “Creating a New Page”Step 1: Create the File
Section titled “Step 1: Create the File”Create a new .md or .mdx file in the appropriate directory:
For Markdown (.md):
touch src/content/docs/guides/my-new-guide.mdFor MDX (.mdx) - with React components:
touch src/content/docs/guides/my-advanced-guide.mdxStep 2: Add Frontmatter
Section titled “Step 2: Add Frontmatter”Every documentation page must start with YAML frontmatter:
---title: My New Guidedescription: A comprehensive guide to using advanced features.---
# My New Guide
Your content goes here...Required Frontmatter Fields
Section titled “Required Frontmatter Fields”| Field | Type | Description |
|---|---|---|
title | string | Page title (appears in browser tab and navigation) |
description | string | Page description for SEO and previews |
Optional Frontmatter Fields
Section titled “Optional Frontmatter Fields”| Field | Type | Description |
|---|---|---|
sidebar.order | number | Custom ordering in sidebar |
sidebar.label | string | Custom label in sidebar (defaults to title) |
sidebar.hidden | boolean | Hide page from sidebar navigation |
editUrl | boolean/string | Enable/disable edit link or set custom URL |
lastUpdated | boolean | Show last updated date |
prev | boolean/object | Configure previous page link |
next | boolean/object | Configure next page link |
hero | object | Add hero section (for splash pages) |
banner | object | Add banner message |
draft | boolean | Mark as draft (won’t build in production) |
Adding to Navigation
Section titled “Adding to Navigation”Method 1: Automatic Generation
Section titled “Method 1: Automatic Generation”For directories with multiple pages, use autogenerate in src/config/config.json:
{ "label": "My Section", "autogenerate": { "directory": "guides" }}Method 2: Manual Configuration
Section titled “Method 2: Manual Configuration”For specific pages or custom organization:
{ "label": "Getting Started", "items": [ { "label": "Introduction", "slug": "getting-started/introduction" }, { "label": "Quick Start", "slug": "getting-started/quick-start" } ]}Method 3: Mixed Approach
Section titled “Method 3: Mixed Approach”Combine autogenerate with manual items:
{ "label": "Guides", "items": [ { "label": "Essential Guide", "slug": "guides/essential" }, { "label": "Advanced Guides", "autogenerate": { "directory": "guides/advanced" } } ]}Content Examples
Section titled “Content Examples”Basic Markdown Page
Section titled “Basic Markdown Page”---title: Getting Started with Componentsdescription: Learn how to use and customize components in your documentation.---
# Getting Started with Components
This guide covers the basics of working with components.
## Overview
Components are reusable pieces of content that help maintain consistency.
### Key Benefits
- **Reusability**: Use the same component across multiple pages- **Consistency**: Maintain uniform styling and behavior- **Maintainability**: Update once, reflect everywhere
## Usage
To use a component:
1. Import it at the top of your MDX file2. Use it in your content3. Pass any required props
```mdximport { Card } from '@astrojs/starlight/components';
<Card title="Example Card"> This is card content.</Card>Next Steps
Section titled “Next Steps”### MDX Page with Components
```mdx---title: Interactive Examplesdescription: Examples with interactive components and code previews.---
import { Tabs, TabItem, Code } from '@astrojs/starlight/components';import NewCard from '~/components/user-components/NewCard.astro';
# Interactive Examples
This page demonstrates interactive components.
<Tabs><TabItem label="Preview"><NewCard title="Example Card" icon="rocket"> This is an example of the NewCard component.</NewCard></TabItem><TabItem label="Code">```astro<NewCard title="Example Card" icon="rocket"> This is an example of the NewCard component.</NewCard>Code Examples
Section titled “Code Examples”<Code code={console.log("Hello, World!");} lang=“js” title=“example.js” />
## Creating New Sections
### Step 1: Create Directory Structure
```bashmkdir -p src/content/docs/my-new-sectionStep 2: Add Pages
Section titled “Step 2: Add Pages”touch src/content/docs/my-new-section/overview.mdtouch src/content/docs/my-new-section/getting-started.mdtouch src/content/docs/my-new-section/advanced-usage.mdStep 3: Update Navigation
Section titled “Step 3: Update Navigation”Add to src/config/config.json:
{ "sidebar": [ // ... existing sections { "label": "My New Section", "items": [ { "label": "Overview", "slug": "my-new-section/overview" }, { "label": "Getting Started", "slug": "my-new-section/getting-started" }, { "label": "Advanced Usage", "slug": "my-new-section/advanced-usage" } ] } ]}Best Practices
Section titled “Best Practices”File Naming
Section titled “File Naming”- Use kebab-case for file names:
my-guide.md - Be descriptive but concise
- Match the URL structure you want
Content Organization
Section titled “Content Organization”- Logical Grouping: Group related content in directories
- Progressive Disclosure: Start with basics, advance to complex topics
- Cross-References: Link related pages together
- Consistent Structure: Use similar headings and organization
Writing Guidelines
Section titled “Writing Guidelines”- Clear Titles: Make titles descriptive and searchable
- Good Descriptions: Write compelling descriptions for SEO
- Proper Headers: Use h1 for page title, h2 for main sections
- Code Examples: Provide working, copy-paste-ready examples
- Visual Elements: Use components, tables, and callouts for clarity
SEO and Accessibility
Section titled “SEO and Accessibility”- Write descriptive
titleanddescriptionfrontmatter - Use proper heading hierarchy (h1 → h2 → h3)
- Add alt text to images
- Use semantic HTML elements
- Test with screen readers
Troubleshooting
Section titled “Troubleshooting”Page Not Appearing in Navigation
Section titled “Page Not Appearing in Navigation”- Check file is in correct directory
- Verify frontmatter syntax
- Ensure page is added to
config.jsonsidebar - Restart development server
Build Errors
Section titled “Build Errors”- Validate YAML frontmatter syntax
- Check for missing imports in MDX files
- Ensure all referenced files exist
- Review component syntax
Navigation Order Issues
Section titled “Navigation Order Issues”- Use
sidebar.orderin frontmatter for custom ordering - Check alphabetical sorting in autogenerated sections
- Verify manual ordering in config.json
Advanced Features
Section titled “Advanced Features”Custom Page Layouts
Section titled “Custom Page Layouts”Use the template frontmatter field:
---title: Landing Pagetemplate: splashhero: title: Welcome to Our Docs tagline: Everything you need to get started---Page-Specific Styling
Section titled “Page-Specific Styling”Add custom CSS classes:
---title: Styled Page---
<div class="custom-content"> # Custom Styled Content
This content has custom styling applied.</div>
<style>.custom-content { background: linear-gradient(45deg, #ff6b6b, #4ecdc4); padding: 2rem; border-radius: 8px;}</style>Conditional Content
Section titled “Conditional Content”Use MDX to show content conditionally:
import { Aside } from '@astrojs/starlight/components';
# Feature Documentation
{process.env.NODE_ENV === 'development' && ( <Aside type="caution"> This feature is still in development. </Aside>)}
Regular documentation content...