category.json
Overview
The _category_.json file is a configuration file commonly used in documentation systems such as Docusaurus to define metadata for a folder or directory within the documentation structure. Its primary purpose is to organize the documentation content by grouping related documents under a named category, setting the category’s position in the sidebar navigation, and optionally providing a link for the category itself.
This particular _category_.json file defines a category labeled "Contribution" that appears as the 8th item in the sidebar. It also sets up a generated index page for this category with a description pointing to miscellaneous contribution guides.
Detailed Explanation
The file contains a JSON object with the following properties:
Properties
Property | Type | Description |
|---|---|---|
String | The display name of the category as it appears in the documentation sidebar. | |
| Number | Determines the order of the category in the sidebar. Categories with lower numbers appear higher up. |
| Object | Defines the behavior and content of the category’s landing page or index. |
link Object Properties
Property | Type | Description |
|---|---|---|
| String | Specifies the type of link. Here, |
| String | A short description shown on the generated index page, summarizing the category's content. |
Usage Example
When placed inside a folder in your documentation directory, this _category_.json file will:
Group all documents in that folder under the "Contribution" category.
Show "Contribution" as the label in the sidebar, positioned at the 8th place.
Create a generated index page for the category with the description "Miscellaneous contribution guides."
Example folder structure:
docs/
├── contribution/
│ ├── _category_.json
│ ├── guide1.md
│ ├── guide2.md
This results in a sidebar entry:
Contribution (position 8)
guide1
guide2
Implementation Details
The
positionproperty is optional but helps in customizing the order of categories in the sidebar.The
link.type = "generated-index"instructs the documentation generator (e.g., Docusaurus) to generate a category landing page automatically, listing all documents in this category with the provided description.This JSON configuration is read by the documentation site generator at build time to structure and render navigation menus.
Interaction with Other Parts of the System
The
category.jsonfile interacts with the documentation generator tool (e.g., Docusaurus) which uses this metadata to build sidebar navigation and category index pages dynamically.It affects how documents within the same folder are grouped and displayed in the documentation UI.
Changes to this file modify the navigation experience without altering the content of individual markdown documents.
Mermaid Diagram
The following flowchart depicts the role of the _category_.json file in the documentation structure and how it configures the category page and sidebar entry:
flowchart TD
A[_category_.json] --> B[Category Label: "Contribution"]
A --> C[Position: 8 in Sidebar]
A --> D[Generated Index Page]
D --> E["Description: Miscellaneous contribution guides."]
B --> F[Sidebar Navigation]
F --> G[Documents in Folder]
Summary
The _category_.json file is a lightweight, declarative configuration file that organizes documentation content into named categories with custom ordering and optional index pages. It is essential for maintaining a logical and user-friendly documentation navigation structure and is widely used in static site documentation generators.