Appearance
How to Add a New Category
This document provides instructions on how to add a new category to the TechLink Hub website.
Prerequisites
- You have a local copy of the website's source code.
- You have Node.js installed.
Instructions
Create a New Category Directory:
- Navigate to the
cataloguedirectory. - Create a new directory for your category. The directory name should be a URL-friendly "slug" (e.g.,
my-new-category).
- Navigate to the
Create an
index.mdFile:- Inside the new category directory, create a file named
index.md. - Open the
index.mdfile and add the following frontmatter at the top:
yaml--- title: "My New Category" layout: page sidebar: true categorySlug: "my-new-category" description: "A brief description of the new category." --- <CategoryLinkList />title: The display name of the category.categorySlug: The URL-friendly slug of the category (must match the directory name).description: A short, one-sentence description of the category.
- Inside the new category directory, create a file named
Update the Website Configuration:
- Open the
.vitepress/config.mjsfile. - Add a new entry to the
getCategorySidebarItemsfunction for your new category:
javascriptconst getCategorySidebarItems = () => { return [ // ... existing categories { text: 'My New Category', link: '/catalogue/my-new-category/' }, ] };- Open the
Update the Data File:
- Open a terminal in the root directory of the project.
- Run the following command to update the website's data file:
bashnode generate_data.mjsVerify the Changes:
- Start the local development server and open your browser to check that the new category appears in the sidebar and that the category page is displayed correctly.