category.json
Overview
The _category_.json file is a configuration file used primarily in documentation or knowledge base systems to define metadata for a documentation category or directory. It provides essential information such as the category label, ordering position, and a link to a generated index page that serves as an entry point or overview for the category.
This specific file helps organize the documentation structure, enabling documentation tools to group related content under meaningful labels and generate navigation elements automatically. It is commonly used in static site generators or documentation frameworks like Docusaurus.
File Structure and Content
The file contains a single JSON object with the following properties:
Property | Type | Description |
|---|---|---|
| The display name for the category or section in the documentation sidebar or navigation panel. | |
| An integer defining the order this category should appear relative to others (lower = higher). | |
| An object defining the type of link associated with this category and additional metadata. |
link Object Properties
Property | Type | Description |
|---|---|---|
| Specifies the type of link. In this file, it is | |
| A brief description shown on the generated index page to summarize the category's content or purpose. |
Explanation of Each Property
label: This is the user-facing name shown in the navigation sidebar for the documentation category. In this file, it is"Datasets", which implies the category contains documentation related to datasets.position: Controls the order in which this category appears relative to other categories. A position of0means it will be among the first categories listed.link: Defines a link object that tells the documentation system to generate an index page for this category. The"generated-index"type means the system automatically creates an overview page listing all documents under this category. The description provided will appear on that overview page to guide users.
Usage Example
This file would typically be placed inside a folder representing a documentation category, for example:
docs/
datasets/
_category_.json
dataset1.md
dataset2.md
When the documentation site is generated:
The sidebar will show a section labeled Datasets.
The Datasets section will appear at the top of the sidebar due to
"position": 0.Clicking the Datasets label will navigate to the auto-generated index page with a description: "Guides on configuring a knowledge base."
The index page will list all markdown files inside the
datasetsfolder, such asdataset1.mdanddataset2.md.
Important Implementation Details
The
generated-indexlink type automates index page creation, reducing manual maintenance.The
positionproperty is crucial for ordering categories when multiplecategory.jsonfiles exist.This file does not contain actual content or documentation text but metadata to organize and present content.
The JSON format must be valid and parsable by the documentation generator; otherwise, navigation or index generation may fail.
Interaction with Other Parts of the System
Documentation Generator: Tools like Docusaurus parse this file to build the sidebar and category index pages.
Sidebar Navigation: This file influences the labels and order of categories displayed in the sidebar.
Generated Index Page: The
linkproperty triggers the creation of an overview page summarizing the category contents.Markdown Files: Actual documentation content files within the same folder are grouped under this category automatically.
This file acts as a bridge between raw content files and the user-friendly navigation structure of the documentation site.
Mermaid Diagram
flowchart TD
A[_category_.json] --> B[label: "Datasets"]
A --> C[position: 0]
A --> D[link]
D --> D1[type: "generated-index"]
D --> D2[description: "Guides on configuring a knowledge base."]
Diagram Explanation:
The diagram shows the
category.jsonfile at the root.It contains three main properties:
label,position, andlink.The
linkproperty further expands intotypeanddescription, illustrating the nested structure.
Summary
The _category_.json file is a small but essential configuration artifact in documentation projects. It defines the label, order, and index linking behavior for a documentation category, enabling organized, user-friendly navigation and automatic index page generation. It interacts closely with documentation generators and sidebar components to present structured content efficiently.