Add a New Category
Categories are essential for organizing content in documentation websites. They help visitors find guides and enhance site navigation. Follow the steps below to add a new category in T-Doc Theme.
Step 1: Navigate to the Docs Directory
- Open your project directory.
- Go to the src/contents/docs/ folder. This folder contains all documentation content.
Step 2: Create a New Category Directory
- Create a new directory for your category:
- Name the folder based on the category name you want to add. For example:
mkdir src/contents/docs/my-new-category
- Use lowercase letters and hyphens for consistency in folder naming.
- Name the folder based on the category name you want to add. For example:
Step 3: Add an index.md
File
- Inside the new directory (e.g.,
src/contents/docs/my-new-category
), create a file namedindex.md
.- This file contains the metadata for the category.
- Add the following content to the
index.md
file:
Fields Explanation:--- type: category slug: my-new-category title: My New Category description: 'A description for this category.' order: 1 ---
- type: Always set to
category
. - slug: A unique, URL-friendly identifier for the category.
- title: The display name of the category.
- description: A short description of the category.
- order: Specifies the display order of categories, with lower numbers appearing first.
- type: Always set to
Step 4: Regenerate the Site
Once the category is created, regenerate your site to apply the changes:
- Open your terminal and navigate to your project directory.
- Run the following command:
toucan generate
- This updates the site’s content and templates to incorporate the new category.
Step 5: Verify the Category
- Start the local development server:
toucan serve
- Open your browser and go to http://localhost:3000.
- Go to the Docs page to verify that the new category appears in the left-hand documentation menu.
Additional Notes
- Using Categories in Guides:
- To assign a category to a guide, include it in the
category
field of the guide’sindex.md
file. Example:category: my-new-category
- To assign a category to a guide, include it in the
This guide will help you easily add and manage categories in T-Doc Theme.