Skip to content

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

  1. Create a New Category Directory:

    • Navigate to the catalogue directory.
    • Create a new directory for your category. The directory name should be a URL-friendly "slug" (e.g., my-new-category).
  2. Create an index.md File:

    • Inside the new category directory, create a file named index.md.
    • Open the index.md file 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.
  3. Update the Website Configuration:

    • Open the .vitepress/config.mjs file.
    • Add a new entry to the getCategorySidebarItems function for your new category:
    javascript
    const getCategorySidebarItems = () => {
      return [
          // ... existing categories
          { text: 'My New Category', link: '/catalogue/my-new-category/' },
        ]
    };
  4. 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:
    bash
    node generate_data.mjs
  5. Verify 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.

Explore, Learn, Share. | Sitemap