category.json
Overview
The _category_.json file is a configuration file used to define a category folder within a documentation or content management system (CMS), such as Docusaurus or similar static site generators. Its primary purpose is to provide metadata about the category, including its label, position order, and an optional link to an index page or other related documentation.
This file helps organize content into logical groups (categories) and allows for customized navigation and presentation in the generated documentation site.
File Structure and Properties
The file contains a single JSON object with the following key properties:
Property | Type | Description |
|---|---|---|
| string | The name of the category as it will appear in navigation menus. |
| integer | Controls the order of the category among its siblings. Lower values appear first. |
| object (optional) | Defines a special link for the category, often pointing to an autogenerated index or landing page. |
Detailed Explanation of Each Property
label
Purpose: Sets the display name of the category.
Example:
"Models"Usage: This string is shown in the sidebar or navigation menu of the documentation site.
position
Purpose: Determines the sorting order of the category relative to others.
Example:
-1Usage: Categories with lower position values appear before those with higher values. Negative values can be used to place a category at the start.
link
Purpose: Defines a link associated with the category, often to a generated index page that summarizes or links to documents within the category.
Sub-properties:
type: Specifies the kind of link, e.g.,"generated-index".description: A short description shown on the linked index page.
Example:
"link": { "type": "generated-index", "description": "Guides on model settings." }Usage: When set, the category header becomes clickable and leads to an index page automatically generated from the category's contents.
Usage Example
Assuming this _category_.json is placed inside a directory named models/, the documentation generator will:
Create a category labeled Models.
Position this category at the top of the sidebar (due to
position: -1).Link the category header to an autogenerated index page described as "Guides on model settings."
This helps users quickly find all related documents about models grouped under this category.
Implementation Details and Algorithms
The file itself is a static JSON configuration; no algorithms are included.
The documentation generator parses this file to:
Order categories based on
position.Display
labelin the navigation.Generate or link to an index page if
link.typeis"generated-index".
The
"generated-index"type triggers the system to scan the category folder, collect markdown files or documents, and create a summary landing page automatically.
Interaction with Other Parts of the System
Documentation content files: The directory containing this
category.jsontypically holds markdown or documentation files that belong to the category.Documentation generator (e.g., Docusaurus): Reads this file to build the sidebar menu and category landing pages.
Site navigation: Uses the metadata here to structure the sidebar and provide user-friendly access to grouped content.
Index page generation: The
"generated-index"link type engages the system's index page creation feature, providing a cohesive overview of the category.
Visual Diagram
The diagram below illustrates the role of the _category_.json file within the documentation system workflow:
flowchart TD
A[_category_.json] --> B[Documentation Generator]
B --> C[Sidebar Navigation]
B --> D[Category Index Page]
D --> E[Content Files in Category Folder]
C --> F[User Interface]
category.json provides metadata.
The Documentation Generator uses this metadata.
It builds the Sidebar Navigation and the Category Index Page.
The Category Index Page aggregates the Content Files in Category Folder.
The Sidebar Navigation and Index Page are rendered in the User Interface.
Summary
category.jsonis a metadata file that defines category properties for a documentation folder.It controls label, order, and linking behavior for the category.
The
"generated-index"link type enables automatic creation of summary pages.It plays a crucial role in navigation and content organization in static documentation sites.
This file is essential for maintaining a clear, user-friendly structure in large documentation projects by grouping related content and facilitating easy navigation.