> For the complete documentation index, see [llms.txt](https://docs.foodcore.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.foodcore.io/recipes/sub-recipes.md).

# Sub-recipes

A sub-recipe is a recipe used as an ingredient inside another recipe. It's one of the most useful features in FoodCore for kitchens that prepare components in advance or share a base across multiple finished products — and it saves you a lot of duplicated data entry.

## When to use sub-recipes

Sub-recipes are the right tool when:

* **You make a component batch and use it across several products** — a shortcrust pastry case, a cream cheese frosting, a spiced syrup, a gluten-free sponge base. Define the component once, use it in as many finished recipes as you like.
* **You cost by component batch** — if your pastry chef makes a 2kg batch of pastry at a time and divides it between several products, a sub-recipe lets you cost the batch correctly and then apportion it by weight.
* **A component has its own allergen complexity** — instead of duplicating allergen data across every product that uses the same base, you set it once on the sub-recipe and it rolls up into everything that contains it.
* **Your production involves distinct stages** — for example, a filled cake where the sponge, the syrup, and the buttercream are all made separately before assembly.

## How to add a sub-recipe to a recipe

Sub-recipes are added exactly like ingredients — FoodCore searches both ingredients and recipes when you type in the ingredients search box.

1. Open the recipe you want to add the sub-recipe to (the "parent" recipe).
2. Click the **Ingredients** tab.
3. In the ingredient search box, **type the name of your sub-recipe**. Both ingredients and recipes appear in the results. Recipes are usually indicated with a small icon or label to distinguish them from ingredients.
4. **Select the sub-recipe** from the results.
5. **Enter the quantity** — how much of the sub-recipe goes into this batch. This is usually a weight (e.g. 400g of pastry), but can be in whatever unit makes sense.
6. **Save** the parent recipe.

## How costs roll up

When you add a sub-recipe, FoodCore uses the sub-recipe's calculated cost per gram (or per unit) to work out the line cost in the parent recipe — exactly the same way it uses ingredient costs.

**Example:**

* Your shortcrust pastry sub-recipe makes a 1kg batch for £1.80 total.
* That means the pastry costs £0.0018 per gram.
* You use 400g of pastry in a quiche recipe.
* FoodCore adds £0.72 as the pastry line cost in the quiche.

If you update any ingredient inside the pastry sub-recipe (say, butter goes up in price), the sub-recipe's cost updates when you recompute it — and then when you recompute the quiche, the new pastry cost flows through automatically.

## How allergens roll up

Allergens from a sub-recipe roll up into the parent recipe in the same way they do from individual ingredients. If your pastry contains gluten and milk, any recipe that uses that pastry as a sub-recipe will show gluten and milk in its allergen summary.

You don't need to set allergens again on the parent recipe — they're inherited from the sub-recipe, which in turn inherits from its own ingredients. The chain is automatic.

## How nutrition values roll up

If you've entered nutrition values on the sub-recipe's ingredients, those values roll up into the sub-recipe's per-100g nutrition, and then into the parent recipe's per-serving nutrition. For products with complex multi-component builds, this means you only enter nutrition data once — at ingredient level — and FoodCore handles the composition maths all the way up.

## Nesting sub-recipes

You can nest sub-recipes — a sub-recipe can itself contain another sub-recipe. For example, a finished gateau might contain a sponge sub-recipe, which itself contains a syrup sub-recipe. FoodCore follows the chain and rolls up costs, allergens, and nutrition all the way through.

Try not to make the nesting too deep — beyond two or three levels it can become difficult to trace where a cost or allergen is coming from if something looks wrong.

## Check that the sub-recipe is published

A sub-recipe doesn't need to be published to be added to a parent recipe, but it does need to exist in FoodCore. If you're finding that a recipe isn't appearing in the search results when you try to add it as a sub-recipe, check that it has been saved. Draft status is fine.

## What's next

* [Create a recipe](https://docs.foodcore.io/recipes/create-recipe.md)
* [How costing works](https://docs.foodcore.io/recipes/how-costing-works.md)
* [Set allergens on an ingredient](https://docs.foodcore.io/ingredients/allergens.md)
* [Generate a label from a finished recipe](https://github.com/CharliesGFTreats/foodcore-docs/blob/master/labels/generate-label.md)
