---
title: "How Auto-Generation Works"
description: "Understand how PID^TOO|| automatically discovers and organizes files"
---

Auto-generation is one of PID^TOO||' most powerful features. Enable it on a group, and files automatically appear in the sidebar without additional configuration.

## What is Auto-Generation?

When `autoGenerated: true`, the system:

1. Scans the folder matching your group ID (or configured path)
2. Finds all `.md` and `.mdx` files
3. Creates entries sorted alphabetically
4. Updates automatically when you add new files

## Basic Example

### Configuration

```typescript
{
    id: "features",
    label: "Features",
    autoGenerated: true,  // <- Enable auto-discovery
}
```

### File Structure

```
content/my-docs/features/
��� auto-generation.md      <- Automatically discovered
��� breadcrumbs.md          <- Automatically discovered
��� icons.md                <- Automatically discovered
���� table-of-contents.md    <- Automatically discovered
```

### Result

Sidebar automatically shows:

```
Features
��� Auto Generation       (sorted alphabetically)
��� Breadcrumbs
��� Icons
���� Table Of Contents
```

No configuration needed for each file!

## How Labels Are Generated

Filenames are converted to readable labels:

```
File: auto-generation.md
-> Slug: auto-generation
-> Label: "Auto Generation"  (title-cased, dashes to spaces)

File: rest-api-integration.md
-> Slug: rest-api-integration
-> Label: "Rest Api Integration"  (each word title-cased)

File: FAQ.md
-> Slug: faq
-> Label: "Faq"
```

Override with frontmatter if needed:

```yaml
---
title: "Frequently Asked Questions"  <- Used in browser tab
navLabel: "FAQ"                       <- Used in sidebar
---
```

## Folder Path Matching

By default, group ID matches the folder:

```typescript
// Group ID: "features"
{ id: "features", label: "Features", autoGenerated: true }
// Looks in: content/[collection]/features/
```

Customize with `path`:

```typescript
// Group ID: "help"
// But scan folder: "common-questions"
{
    id: "help",
    label: "Help",
    autoGenerated: true,
    path: "common-questions",
}
// Looks in: content/[collection]/common-questions/
```

## Filtering Files

Auto-generation respects frontmatter flags:

### Hide Specific Pages

```yaml
---
title: "Internal Notes"
navHidden: true  <- Won't appear in sidebar
---
```

Page is still accessible via direct URL but doesn't appear in navigation.

### Draft Pages

```yaml
---
title: "Work in Progress"
draft: true  <- Excluded from production build
---
```

### Result

```
Features
��� Auto Generation
��� Breadcrumbs
��� Icons
��� Table Of Contents
(Internal Notes doesn't appear)
```

## Ordering

Auto-discovered files are sorted **alphabetically by filename** (case-insensitive):

```
Files:
��� 01-introduction.md        <- Appears first
��� 02-installation.md        <- Appears second
��� advanced.md               <- Auto-alphabetically ordered
��� breadcrumbs.md
��� configuration.md
��� deployment.md
���� zz-advanced.md           <- Appears last
```

To control order:

- Use numeric prefixes: `01-intro.md`, `02-install.md`
- Or use manual configuration (see next section)

## Auto-Generation with Nested Groups

Auto-discovery works at every level:

```typescript
{
    id: "documentation",
    label: "Documentation",
    groups: [
        {
            id: "guides",
            label: "Guides",
            autoGenerated: true,  // Scans content/my-docs/documentation/guides/
        },
        {
            id: "api",
            label: "API",
            groups: [
                {
                    id: "endpoints",
                    label: "Endpoints",
                    autoGenerated: true,  // Scans content/my-docs/documentation/api/endpoints/
                },
            ],
        },
    ],
}
```

## Real-World Examples

### Documentation Site

```typescript
{
    id: "docs",
    label: "Documentation",
    autoGenerated: true,
}
```

Create files, they appear automatically:

```
content/my-docs/
��� getting-started.md
��� installation.md
��� configuration.md
��� advanced-setup.md
```

Sidebar shows alphabetically.

### Feature List

```typescript
{
    id: "features",
    label: "Features",
    autoGenerated: true,
}
```

Add feature docs:

```
content/my-docs/features/
��� authentication.md
��� caching.md
��� webhooks.md
```

Updates automatically.

## When to Use Auto-Generation

 **Good for:**

- Growing documentation
- Large numbers of pages
- Frequently changing content
- Alphabetical ordering acceptable
- Multiple people contributing

� **Not ideal for:**

- Specific ordering required
- Carefully curated selection
- Hide many files from navigation
- Need custom labels throughout

## Combining with Manual Entries

Use `entries` + `autoGenerated: true` for hybrid approach:

```typescript
{
    id: "guides",
    label: "Guides",
    entries: [
        { slug: "guides/overview" },      // Always first
        { slug: "guides/quick-start" },   // Always second
    ],
    autoGenerated: true,  // Rest auto-discovered
}
```

See [Hybrid Approach](/docs/generation-strategies/hybrid-approach/best-of-both) for details.

## Performance

Auto-generation happens at build time, not runtime. Performance impact is negligible even with 1000+ files.

## Troubleshooting

**Files not appearing?**

- Check file is in correct folder
- Verify `autoGenerated: true` is set
- Look for `navHidden: true` in frontmatter
- Check `draft: true` in frontmatter

**Order is wrong?**

- Use numeric prefixes: `01-`, `02-`, etc.
- Or use manual entries for precise control

**Label looks wrong?**

- Add `navLabel:` to frontmatter
- Or override in manual entries

## Next Steps

Learn about:

- [Manual Creation](/docs/generation-strategies/manual-creation/explicit-control)
- [Hybrid Approach](/docs/generation-strategies/hybrid-approach/best-of-both)
- [Configuration Examples](/docs/configuration/basics/sidebar-structure)
