Heat oven to 200C/fan 180C/gas 6.
Fry the onions and thyme sprigs in the oil until softened and lightly coloured (about 5 mins).
Spread a layer of potatoes over the base of a 1.
5-litre oiled gratin dish.
Sprinkle over a few onions (see picture, above) and continue layering, finishing with a layer of potatoes.
Pour over the stock and bake for 50-60 mins until the potatoes are cooked and the top is golden and crisp.