# How Recipes Are Categorized Into Dish Types in the HowToCook Repository

> Discover how recipes are categorized into dish types in the HowToCook repository. Learn to organize your culinary creations by organizing Markdown files into subdirectories under the dishes folder. Explore categories like veget...

- Repository: [Anduin Xue/HowToCook](https://github.com/Anduin2017/HowToCook)
- Tags: how-to-guide
- Published: 2026-02-27

---

**Recipes are categorized into dish types by organizing Markdown files into subdirectories under the `dishes/` folder, where each folder name represents a specific culinary category such as `vegetable_dish`, `meat_dish`, or `dessert`.**

The **Anduin2017/HowToCook** repository uses a simple but effective folder-based taxonomy to classify recipes. Instead of relying on metadata tags or databases, the project leverages the filesystem itself to encode how recipes are categorized into dish types, making the structure immediately browsable and machine-readable.

## The Folder Hierarchy as a Classification System

The primary mechanism for categorization resides in the `dishes/` directory at the repository root. Each subdirectory within `dishes/` represents a distinct dish type:

```

dishes/
├─ vegetable_dish/   # 素菜 (vegetable-based recipes)

├─ meat_dish/        # 荤菜 (meat-based recipes)

├─ staple/           # 主食 (rice, noodles, dumplings)

├─ dessert/          # 甜品 (sweet dishes)

├─ drink/            # 饮品 (beverages)

├─ condiment/        # 酱料 (sauces and condiments)

├─ soup/             # 汤类 (soups)

└─ breakfast/        # 早餐 (breakfast items)

```

Individual recipe files are nested two levels deep: first by dish type, then by dish name. For example, `dishes/vegetable_dish/鸡蛋羹/鸡蛋羹.md` places the steamed egg recipe firmly in the vegetable dish category, while `dishes/meat_dish/回锅肉/回锅肉.md` categorizes the twice-cooked pork as a meat dish.

## How the README Indexes Dish Types

The top-level [`README.md`](https://github.com/Anduin2017/HowToCook/blob/main/README.md) serves as the human-readable index that maps Chinese culinary terms to these folder names. It groups links under headers like **“素菜”** (vegetable dishes) and **“荤菜”** (meat dishes), directing users to the corresponding subdirectories【/cache/repos/github.com/Anduin2017/HowToCook/master/README.md†L63-L88】.

This dual-layer approach—filesystem folders for machines, README sections for humans—ensures that recipes remain categorized consistently whether accessed programmatically or browsed manually.

## Adding New Recipes Using the Template

The repository enforces categorization through its contribution workflow. Authors must copy the template from `dishes/template/示例菜/示例菜.md` and place it within the appropriate dish type folder【/cache/repos/github.com/Anduin2017/HowToCook/master/dishes/template/示例菜/示例菜.md†L5-L10】.

This physical placement requirement guarantees that every new submission is explicitly categorized by its location in the hierarchy, preventing uncategorized or ambiguously classified recipes from entering the collection.

## Programmatically Accessing Dish Type Categories

Because dish types are encoded as directory names, you can extract categorization data using simple path parsing.

### List all recipes in a specific category (Bash)

```bash

# List every markdown recipe under the “vegetable_dish” category

find dishes/vegetable_dish -name "*.md" -type f

```

### Extract dish type from file path (Node.js)

```javascript
const path = require('path');

function getDishType(recipePath) {
  // recipePath → 'dishes/vegetable_dish/鸡蛋羹/鸡蛋羹.md'
  const parts = recipePath.split(path.sep);
  // parts[1] is the type folder (e.g. 'vegetable_dish')
  return parts[1];
}

// Usage
const recipe = 'dishes/meat_dish/回锅肉/回锅肉.md';
console.log(getDishType(recipe));   // → meat_dish

```

## Summary

- **HowToCook** categorizes recipes into dish types using a filesystem-based hierarchy under the `dishes/` directory.
- Each subdirectory name—such as `vegetable_dish`, `meat_dish`, `staple`, or `dessert`—represents a distinct culinary category.
- Recipe files are nested within these folders, making their classification immediately apparent from their path.
- The [`README.md`](https://github.com/Anduin2017/HowToCook/blob/main/README.md) provides a human-readable index that maps these folders to Chinese culinary terms like **素菜** and **荤菜**.
- New contributions must use the template in `dishes/template/示例菜/示例菜.md` and be placed in the appropriate category folder, enforcing consistent classification.

## Frequently Asked Questions

### What are the main dish type categories in HowToCook?

The primary categories include `vegetable_dish` (素菜), `meat_dish` (荤菜), `staple` (主食), `dessert` (甜品), `drink` (饮品), `soup` (汤类), `condiment` (酱料), and `breakfast` (早餐). Each category exists as a subdirectory under `dishes/`.

### How does the repository distinguish between vegetable and meat dishes?

Vegetable dishes reside in `dishes/vegetable_dish/` while meat dishes are stored in `dishes/meat_dish/`. The [`README.md`](https://github.com/Anduin2017/HowToCook/blob/main/README.md) explicitly links to these folders under the headers **“素菜”** and **“荤菜”**, creating a clear separation between plant-based and meat-based recipes.

### Can a recipe belong to multiple dish types?

No, the current filesystem-based architecture assigns each recipe to exactly one dish type folder. A recipe like `dishes/meat_dish/回锅肉/回锅肉.md` cannot simultaneously exist in `vegetable_dish/`. Cross-category dishes must choose their primary classification or be duplicated, though the repository discourages this.

### Where is the template for adding new recipes located?

The canonical template is located at `dishes/template/示例菜/示例菜.md`. Authors copy this file into the appropriate dish type subdirectory (e.g., `dishes/dessert/`) and rename it to match their recipe, ensuring the new entry follows the established format and resides in the correct category from the start.