File Structure

How to organize your documentation files

File Structure

OI Laravel Documentation uses a hierarchical file-based structure that automatically generates navigation. Understanding this structure is key to organizing your documentation effectively.

Directory Layout

Your documentation lives in resources/markdown/docs/ (configurable) and follows this pattern:

resources/markdown/docs/
β”œβ”€β”€ meta.json                          # Root metadata
β”œβ”€β”€ getting-started/
β”‚   β”œβ”€β”€ meta.json                      # Section metadata
β”‚   β”œβ”€β”€ _index.md                      # Section homepage
β”‚   β”œβ”€β”€ installation.md
β”‚   └── configuration.md
β”œβ”€β”€ configuration/
β”‚   β”œβ”€β”€ meta.json
β”‚   β”œβ”€β”€ _index.md
β”‚   β”œβ”€β”€ basic-setup.md
β”‚   └── advanced-options.md
β”œβ”€β”€ guides/
β”‚   β”œβ”€β”€ meta.json
β”‚   β”œβ”€β”€ _index.md
β”‚   β”œβ”€β”€ common-tasks/
β”‚   β”‚   β”œβ”€β”€ meta.json                  # Subsection metadata
β”‚   β”‚   β”œβ”€β”€ _index.md
β”‚   β”‚   └── working-with-data.md
β”‚   └── troubleshooting/
β”‚       β”œβ”€β”€ meta.json
β”‚       β”œβ”€β”€ _index.md
β”‚       └── common-issues.md
└── api-reference/
    β”œβ”€β”€ meta.json
    β”œβ”€β”€ _index.md
    └── endpoints.md

Required Files

Root meta.json

The root docs/meta.json defines your documentation package:

json
{
    "type": "package",
    "name": "my-package-name",
    "title": "Documentation Title",
    "description": "Short description",
    "version": "1.0.0"
}

Fields:

  • type - Always "package" (used for package imports)
  • name - Package identifier (vendor/package format recommended)
  • title - Display name
  • description - Short summary
  • version - Documentation version (optional)

This file is not shown in navigation but provides metadata for the entire documentation set.

Section meta.json

Each section folder requires a meta.json:

json
{
    "type": "section",
    "title": "Getting Started",
    "description": "Installation and setup guide",
    "order": 1
}

Fields:

  • type - Always "section"
  • title - Section display name
  • description - Section description (shown in navigation)
  • order - Sort order (lower numbers appear first)

Without meta.json, a section is skipped with a warning in console output.

The _index.md Pattern

The _index.md file in each section serves as the section's homepage:

getting-started/
β”œβ”€β”€ meta.json
β”œβ”€β”€ _index.md          # This is the section homepage
β”œβ”€β”€ installation.md
└── configuration.md

When you navigate to /documentation/getting-started, you're viewing _index.md.

The URL structure follows folder nesting:

  • getting-started/_index.md β†’ /documentation/getting-started
  • guides/common-tasks/_index.md β†’ /documentation/guides/common-tasks
  • getting-started/installation.md β†’ /documentation/getting-started/installation

Nested Sections

You can nest sections to any depth. Each level requires its own meta.json:

guides/
β”œβ”€β”€ meta.json                      # Section
β”œβ”€β”€ _index.md
β”œβ”€β”€ common-tasks/
β”‚   β”œβ”€β”€ meta.json                  # Subsection
β”‚   β”œβ”€β”€ _index.md
β”‚   └── working-with-data.md
β”œβ”€β”€ advanced/
β”‚   β”œβ”€β”€ meta.json
β”‚   β”œβ”€β”€ _index.md
β”‚   β”œβ”€β”€ caching/
β”‚   β”‚   β”œβ”€β”€ meta.json              # Sub-subsection
β”‚   β”‚   β”œβ”€β”€ _index.md
β”‚   β”‚   └── strategies.md
β”‚   └── optimization.md
└── troubleshooting/
    β”œβ”€β”€ meta.json
    β”œβ”€β”€ _index.md
    └── common-issues.md

This creates a navigation tree:

  • Guides
    • Common Tasks
      • Working with Data
    • Advanced
      • Caching
        • Strategies
      • Optimization
    • Troubleshooting
      • Common Issues

Naming Conventions

File Naming

Use lowercase filenames with hyphens:

βœ“ getting-started.md
βœ“ installation-steps.md
βœ— GettingStarted.md
βœ— Installation_Steps.md

Section Naming

Section folder names match the URL path and should be descriptive:

βœ“ getting-started/
βœ“ configuration/
βœ“ api-reference/
βœ— getting-started-guide/      (Too verbose)
βœ— config/                       (Too ambiguous)

Ordering Files

Use numerical prefixes for strict ordering (optional):

01-installation.md
02-configuration.md
03-usage.md

Or specify order in frontmatter:

yaml
---
title: Installation
order: 1
---

Both methods workβ€”use whichever you prefer.

Auto-Generation Files

The package automatically generates two JSON files. Never edit these manuallyβ€”they're regenerated by commands:

Auto-generated by doc:gen-nav:

json
{
    "sections": [
        {
            "title": "Getting Started",
            "slug": "getting-started",
            "description": "Installation and setup",
            "order": 1,
            "pages": [
                {
                    "title": "Introduction",
                    "slug": "getting-started",
                    "url": "/documentation/getting-started"
                },
                {
                    "title": "Installation",
                    "slug": "installation",
                    "url": "/documentation/getting-started/installation"
                }
            ]
        }
    ]
}

search-index.json

Auto-generated by doc:gen-index:

json
{
    "documents": [
        {
            "id": "getting-started",
            "title": "Getting Started",
            "section": "Getting Started",
            "description": "Installation and setup",
            "url": "/documentation/getting-started",
            "content": "...",
            "headings": ["Installation", "Configuration"],
            "score": 0
        }
    ]
}

Organizing Large Documentation

By Feature

Organize documentation around features:

features/
β”œβ”€β”€ authentication/
β”œβ”€β”€ authorization/
β”œβ”€β”€ payments/
└── notifications/

By Audience

Organize for different users:

docs/
β”œβ”€β”€ user-guide/
β”œβ”€β”€ developer-guide/
β”œβ”€β”€ api-reference/
└── admin-manual/

By Topic

Group related topics:

docs/
β”œβ”€β”€ getting-started/
β”œβ”€β”€ core-concepts/
β”œβ”€β”€ tutorials/
β”œβ”€β”€ how-to-guides/
β”œβ”€β”€ reference/
└── troubleshooting/

Regenerating Navigation

After adding, removing, or renaming files or folders, regenerate navigation:

bash
php artisan doc:gen-nav

After content changes, regenerate search index:

bash
php artisan doc:gen-index

Or both:

bash
php artisan doc:gen-nav && php artisan doc:gen-index

Best Practices

  1. Always include meta.json in sections - Prevents warnings and ensures proper ordering
  2. Use _index.md for section homes - Makes section landing pages consistent
  3. Keep folder depth reasonable - Maximum 3-4 levels is typical
  4. Use descriptive names - File names should indicate content
  5. Group related pages - Keep similar topics in the same section
  6. Regenerate after changes - Always run generation commands after file changes
  7. Test navigation - Visit your docs to ensure structure is correct

Common Mistakes

Missing meta.json in a section:

⚠ Section "guides" has no meta.json and will be skipped

Using capital letters in folder names:

❌ GettingStarted/  β†’ URL becomes /documentation/GettingStarted
βœ“ getting-started/  β†’ URL becomes /documentation/getting-started

Not regenerating navigation:

New files appear in filesystem but not in navigation menu.
Solution: Run `php artisan doc:gen-nav`

Forgetting _index.md:

Section exists but has no homepage. Create docs/section/_index.md.
Project under MIT License.
Design by