index-files
Index File Handling
DocBuilder automatically generates index pages for repositories and sections, but also respects user-provided index files. This document explains how index files are discovered, processed, and what takes precedence when multiple options exist.
Overview
DocBuilder generates Hugo _index.md files at three levels:
- Site Level: Main landing page (
content/_index.md) - Repository Level: Repository overview pages (
content/{repository}/_index.md) - Section Level: Section overview pages (
content/{repository}/{section}/_index.md)
Users can provide their own index content to replace auto-generated indexes.
Repository-Level Indexes
At the repository level (directly under the configured paths), DocBuilder supports three scenarios:
Case 1: README.md Only
When a repository contains only a README.md file at the root of the docs path:
Behavior: README.md is used as the repository’s main index page.
Case 2: No User-Provided Index
When neither README.md nor index.md exists:
Behavior: DocBuilder auto-generates a repository index listing sections and documents.
Case 3: index.md Only
When a repository contains an index.md file:
Behavior: index.md is used as the repository’s main index page.
Case 4: Both index.md and README.md
When both files exist at the repository root:
Behavior:
index.mdtakes precedence and becomes the repository’s_index.mdREADME.mdis copied as a regular document and accessible at/repo/readme/
Precedence Order: index.md > README.md > auto-generated
Section-Level Indexes
Within sections (subdirectories), only index.md files are recognized as section indexes:
Behavior: index.md in a section directory becomes that section’s _index.md.
If no index.md exists, DocBuilder generates a section index listing all documents in that section.
File Naming Conventions
Important notes about file naming:
- Case-Insensitive:
README.md,readme.md,Readme.mdare all treated the same - Lowercase URLs: Files are converted to lowercase for URLs (
README.md→/repo/readme/) - index.md Conversion: Files named
index.mdare automatically converted to_index.mdin Hugo’s content directory
Configuration Impact
Forge-Discovered Repositories
Repositories discovered via forge auto-discovery (GitLab, GitHub, Forgejo) default to using ["docs"] as their documentation paths:
For these repositories, place your index.md or README.md at:
docs/index.md(repository index)docs/section-name/index.md(section index)
Explicitly Configured Repositories
For explicitly configured repositories, you control the documentation paths:
Index files should be placed at the root of each configured path:
documentation/index.mdguides/index.md
Front Matter in User-Provided Indexes
User-provided index files can include Hugo front matter:
If no front matter is present, DocBuilder adds minimal front matter automatically:
Ignored Files
The following files are ignored at the repository root level (but can exist in subdirectories):
CONTRIBUTING.mdCHANGELOG.mdLICENSE.md
These are typically repository-level documentation not relevant to the generated docs site.
Exception: As shown above, README.md is not ignored and can be used as the repository index or a regular document depending on whether index.md exists.
Best Practices
-
Use index.md for Docs Sites: If you’re building a dedicated documentation site, use
index.mdfor repository and section indexes. ReserveREADME.mdfor GitHub/GitLab repository overview. -
Keep README.md for Dual Purpose: If your repository README is also suitable as docs landing page, use
README.mdand skipindex.md. -
Section Organization: Always provide
index.mdfiles in section directories to give users context about what’s in that section. -
Front Matter: Add proper front matter to control titles, descriptions, and ordering in navigation.
Examples
Example 1: Technical Documentation with Separate README
Result:
- Site uses
docs/index.mdas repository index - GitHub shows root
README.md - Root
README.mdnot included in docs site
Example 2: Simple Project with README as Docs
Result:
docs/README.mdbecomes repository index- Simple structure for small projects
Example 3: Multi-Language Documentation
Result:
- Clear index pages at each level
- Language sections well-organized
Troubleshooting
Q: My index.md isn’t being used as the repository index
A: Ensure:
- File is at the root of your configured
pathsdirectory - File is named exactly
index.md(case-insensitive) - File has
.mdextension - Repository has been rebuilt (daemon mode requires rebuild trigger)
Q: README.md is missing from my site when I have both README.md and index.md
A: This is expected behavior. When index.md exists, it takes precedence for the repository index, and README.md becomes a regular document accessible at /repository/readme/ (lowercase).
Q: My section index.md isn’t showing up
A: Check that:
- File is in a subdirectory (section), not at repository root
- Section is not empty (contains other .md files)
- File is being discovered (check verbose logs for “Discovered file”)