Suggestion needed - Writing Recipes

I need to write some recipes in my TiddlyWiki. The usual format. A list of ingredients with quantities, then a list of steps, etc. Plus some classifying information like Lunch or Dinner, Thai or Indian, etc.

I will like the recipes to be searchable by ingredient. So, that data needs to go in a field.

But a list like ‘potatoes tomatoes onions’ in the field ‘ingredients’ is pointless because it does not have quantities.

What I need to have is:

potatoes: 250g
tomatoes: 200g
onions: 100g

And the number of ingredients will, of course, vary across recipes. And this needs to go in some kind of field so I can filter using ‘[tag[Recipe]contains:ingredient[potatoes]]’

What is the correct way of doing this?

Maybe you don’t need to bother with fields?

What if your recipe tiddler had the following text:

[[potatoes]]: 250g
[[tomatoes]]: 200g
[[onions]]: 100g

Then, your filter could be:

[tag[Recipe]contains:text[potatoes]]

That way, you can just type in the recipe, even copy and paste it from somewhere, wrap each ingredient in “[[” and “]]”, and you are done.

Well, maybe you don’t need to wrap the ingredients with “[[” and “]]”.

I’m just thinking it could be useful. Your “potatoes” tiddler could list all the recipes that have potatoes.

I just thought of an advantage of having your ingredients right in the tiddler text for a recipe.

You may have a recipe that has ingredients that don’t include potatoes, but you might mention in the recipe that you can replace one of the recipe ingredients with potatoes.

That might not be so convenient if ingredients are all in an “ingredients” field, which might not handle ingredient substitutes all that well?

ADDITION:

Another advantage of wrapping ingredients in “[[” and “]]”.

You might say in a recipe something like “prepare this ingredient the same way as you would potatoes” …

In which case, potatoes isn’t an ingredient. So you wouldn’t want that recipe to show in the list of recipes for potatoes.

The filter for recipes that have potatoes could then be:

[[potatoes]backlinks[]tag[Recipe]]

i.e. give me all of the tiddlers that are backlinks to potatoes. Of those, just give me the tiddlers tagged Recipe.

(Sorry for rapid-succession tiddlers … I’m firing on all cylinders thinking about all of the possibilities. What can I say: I love TiddlyWiki almost as much as I love food, so your use case is pretty awesome to me!)

I’m going to be quiet now …

Instead of using a single list ingredients list field, you could create separate fields for each ingredient, and then use [tag[Recipe]has:field[potatoes] to find those recipes that use potatoes.

The advantage is that the content of each field can then hold the amount of that ingredient as an easily addressable value. Then, you could use that value in calculations, based on how many people the recipe serves.

For example, suppose the recipe normally serves 4 people, and has fields like this:

tags: Recipe
serves: 4
potatoes: 250g
tomatoes: 200g
onions: 100g

You could then calculate how much of each ingredient is needed to serve 6 people, like this:

How many people: <$edit-text tiddler="temp" field="people"/>

<$vars people={{temp!!people}}>
<$vars p={{{ [{!!potatoes}divide{!!serves}multiply<people>] }}}>
<$vars t={{{ [{!!tomatoes}divide{!!serves}multiply<people>] }}}>
<$vars o={{{ [{!!onions}divide{!!serves}multiply<people>] }}}>

To serve <<people>>, you will need
<<p>>g of potatoes, <<t>>g of tomatoes, and <<o>>g of onions.

Don’t. Let the creative juices flow. I can very clearly relate with what you are saying. :slight_smile:

@EricShulman Thanks. Just one thought. There are going to be hundreds of ingredients. I mean it. That will mean hundreds of fields. Will it be OK from the point of view of processing needed to be done, etc.?

This ties in with another question I had asked here.

Also, how does one take care of substitutes as @Charlie_Veniot pointed out in an earlier reply.

I did not expect that, and it made me laugh out loud (I even snorted just a little).

Thanks!

The number of fields is probably not an issue.

And the calculations can be generalized, so that the same code can be used for any given recipe.

Consider the following, tagged with $:/tags/ViewTemplate

<$list filter="[<currentTiddler>tag[Recipe]]">
<$set name="ingredients" filter="[<currentTiddler>fields[]] -[[title]] -[[tags]] -[[text]] -[[created]] -[[modified]] -[[serves]]">

INGREDIENTS: <$text text={{{ [enlist<ingredients>join[, ]] }}}/>

To serve
<$edit-text tiddler="$:/temp/people" tag="input" focus="yes" default="" placeholder={{!!serves}} />,
you will need:
<blockquote>
<$vars people={{{ [{$:/temp/people}!match[]else{!!serves}] }}}>
<$list filter=<<ingredients>> variable="ingredient">
   <$vars amount={{{ [get<ingredient>multiply[1]] }}}> <!-- REMOVES UNITS -->
   <$vars units={{{ [get<ingredient>removeprefix<amount>] }}}> <!-- GETS UNITS -->
   <$text text={{{ [<amount>divide{!!serves}multiply<people>] }}}/><<units>> of <<ingredient>><br>
   </$vars>
   </$vars>
</$list>
</$vars>
</blockquote>
</$set>
</$list>

Then, you can create multiple tiddlers, each tagged with “Recipe”, with fields for each ingredient, plus a field named “serves”, containing the number of people served by that recipe.

enjoy,
-e

1 Like

I’m picking up lots of tips from this, thank your Eric & Charlie!

Think more about how you want to use the site.

I have an ingredients / groceries / shopping / everything food site https://boris.files.fission.name/p/TWGroceries/

It’s a bit of an everything site and I personally tend to riff on recipes, so for me, recipes are for inspiration.

I tend to just have ingredients as a bulleted list, and will [[wikilink]] some of them if they are unique. And, I use ingredients as tags, too — usually just the major ones.

More interesting for me are things like the Cuisine tag — eg Sichuan or German.

I love learning about unique cuisines and ingredients and techniques, so I’ll often fill out tags with a snippet from Wikipedia.

And, keeping the native names for things I use the aliases plugin.

Here’s the shisito pepper and the different names for it as aliases:

It’s tagged generic because this Item is not a brand or from a particular farm.

The Stores at the bottom is a fold out list of Stores I visit and where you can buy an ingredient.

Here’s an example recipe I just put in:

All the ingredients are pretty basic and something I mostly have in my pantry, so I didn’t bother tagging this with “garlic”.

Catalan Cuisine is the name of the cookbook. I want to do something interesting and bi-directional there with display. Showing all the recipes on the cookbook page.

This is just manual right now which lists Recipes tagged with this cookbook tiddler and aliases.

As I put more in and get better at TW templates I’ll turn it into a view template.

Share some screenshots / let us know what you end up with!

1 Like

As someone who cooks, and who has actually tried to create my own recipe database, with quantity fields and all that, I would say – keep it simple. It’s just overwhelming to have to plug in all that data for a recipe that might be experimental. Unless you’re a nutritionist, what are you going to need all those fields for? So just making a standard “card-file” tiddler with recipes turns out to be more practical.

@boris Thanks. This is elaborate and neat. I am amazed at several ideas you have used there.

@Mark_S Thanks. Coming from someone who cooks and keeps a recipe book, these inputs are invaluable. I was wondering if I could make searching a bit easier. Something like breakfast recipe with milk or recipes that contain only potatoes, onions, and tomatoes. etc. should be just as easily possible as it is to enter a recipe.

And I thought normal linking will not work or may not work. I may have to use some field somewhere. So, I was asking.

Hi Eric,
thanks for providing the code example.
If you had a lot of ingredients (fields), how could you select them from a large list, data tiddler or tagged list. Rather than type each ingredient.
Possibly by using checkbox to write to current tiddler field.
Any help with this query would be much appreciated. I am talking about quite a large number of ingredients not just a few.
I asked a similar question in Google Groups some time ago for a parts list (similar idea) and Mark S. suggested
( In that case, a better approach would be to save the parts in the list field of the partslist tiddler. Then enumerate them via <$list> filter as a template)
Discussion below:

https://groups.google.com/g/tiddlywiki/c/jl7GwfSTfGo/m/7B0WsSsMAQAJ

Thanks
Scot

I’m with Mark. My recipe wiki is huge and not getting bogged down by procedure (easily done when you’re a techie) is absolutely key to making your recipe wiki functional and not a recipe for tinkering like most wikis (see what I did there? :upside_down_face: ).

I do use a few macros, but only a few – most recipes are written as vanilla text (perhaps with a picture of the target dish).

But you’re right, great searching capabilities are vital. Have some pre-built searches to hand: ready-made tiddlers with common searches already laid out ready to go: All recipes without salt, All Indian meals using chicken, etc.

Recipes are to cooking like jazz is to music – let the ideas flow, dude.

:man_dancing:

Found a recipe plugin at our links site, and noticed that this thread (top result when searching for “recipe” here) doesn’t mention it. So, I’ll add a pointer here for anyone who comes across this thread:

https://odinjorna.github.io/recipe-plugin/

One glitch I found: renaming the relevant tag (away from “Recipe”) doesn’t change the tag invoked in the popup for choosing a recipe to edit (Recipe plugin — For storing your recipes). There may be other niggling ways that changing the tag leaves loose ends.

-Springer

2 Likes