1

I want to add some recipes to a part of my Mediawiki site and have each ingredient create a relevant category.

This is easy to do by hand, but subject to human error - each ingredient has to be entered twice.

for example


* [[category:apples]] apples
* [[category:bananas]] bananas
* [[category:cherries]] cherries

This works, but I feel there should be a way to automate it however I'm not really sure of what the best way forward would be. Is there already an extension to do this (I've searched on all the terms I can think of), should I be writing a script ? Is there some other method to solve this that I should be looking at ?

David Rose
  • 130
  • 1
  • 8

1 Answers1

1

You could use a template, lets call it Template:Ingredient,

<includeonly>* [[Category:{{{1}}}]] {{{1}}}</includeonly>

Then call it in your page with:

{{Ingredient|apples}}

This will both display the ingredient name and add the page to the category.

IRA1777
  • 593
  • 3
  • 11
  • Brilliant. That does exactly what I need. What would be nice is to also add the category apples to the subcategory ingredients at the same time, but I don't think that's doable and it's not too much work to do that manually. It's an internal Wiki, so the number of new pages per month will be in the 10's rather than 100's or 1000's – David Rose Jul 23 '19 at 11:56