category.json
Overview
The _category_.json file is a configuration file used primarily in documentation or content management systems that organize content into hierarchical categories. Its purpose is to define metadata for a specific category, such as the label (name), position (order), and an associated link configuration. This helps in generating navigational structures, indexes, or menus automatically based on these category definitions.
In this particular instance, the file defines a category named "Team" that appears as the 4th item in a list or menu and links to a generated index page containing team-specific guides.
Detailed Explanation
This file contains a single JSON object with the following properties:
Property | Type | Description |
|---|---|---|
| string | The display name of the category. In this file, it is |
| number | The order or sorting position of this category relative to others. Lower numbers come first. |
| object | Configuration for a link associated with this category. |
link Object Properties
Property | Type | Description |
|---|---|---|
| string | Specifies the kind of link. |
| string | A short description of the link or the content it points to. Here, it is |
Usage Example
Suppose you have a documentation site with multiple categories such as "Introduction", "API", "Guides", and "Team". You want to define the "Team" category so that it appears fourth in the sidebar menu and links to an automatically generated index page that summarizes all team-related guides.
{
"label": "Team",
"position": 4,
"link": {
"type": "generated-index",
"description": "Team-specific guides."
}
}
When the documentation system reads this file, it will:
Display "Team" as a category label.
Sort it to appear fourth in the list.
Create a landing page that automatically lists all documents under this category, described as "Team-specific guides."
Implementation Details
The file follows a strict JSON format.
The
"link"property supports various types;"generated-index"is a special type where the documentation generator automatically creates an index page summarizing the category's contents.The
"position"allows for manual ordering of categories, ensuring consistent navigation structure.This file does not contain any executable code but serves as metadata consumed by the documentation system at build or runtime.
Interaction with Other Parts of the System
The
category.jsonfile is typically placed in a folder representing a documentation category.Documentation generators such as Docusaurus or similar static site generators parse this file to build navigation menus and category landing pages.
The
"generated-index"link type instructs the system to collect all markdown or documentation files in the same category folder and generate an index automatically.This file works alongside content files (e.g.,
.mdor.mdx) and other metadata files to create a coherent navigation experience.
Visual Diagram
The following Mermaid flowchart illustrates how this file interacts with the documentation system to create a category and generate an index page:
flowchart TD
A[_category_.json] --> B[Documentation Generator]
B --> C[Reads "label" & "position"]
B --> D[Reads "link" configuration]
D --> E{Is link.type = "generated-index"?}
E -- Yes --> F[Generate Index Page with description]
E -- No --> G[Use custom link behavior]
F --> H[Display category in navigation menu at "position"]
G --> H
Summary
The _category_.json file is a simple yet crucial configuration artifact that helps organize and present documentation categories. By defining the label, order, and link behavior, it enables automatic generation of category landing pages and intuitive navigation menus, improving the user experience and maintainability of documentation sites.