1. For the pastry, mix the flour, polenta and a pinch of salt in a food processor. Add the cold butter and pulse until the mixture resembles breadcrumbs. Tip into a bowl, add 50g of the grated Parmesan and mix with a table knife until the mixture comes together. Measure out 4 tbsp cold water and add a little at a time until the dough just sticks together (you may not need all the water). Knead it gently until it forms a ball, wrap the pastry in cling film and chill for 20 minutes in the fridge.
2. Meanwhile, preheat the oven to 200°C/fan180°C/gas 6. Scatter the sliced butternut squash over 2 or 3 large roasting trays, drizzle with half the olive oil, scatter over the cumin seeds, ras el hanout and chilli flakes, and season well with salt and black pepper. Roast in the oven, stirring occasionally, for 40 minutes.
3. Meanwhile, add the sliced onions and garlic to another roasting tin with the rest of the olive oil. Halfway through cooking the squash, add the onions to the oven and roast for 20 minutes. Remove the squash and onions from the oven, squeeze out the garlic from their skins, mash the roasted garlic into the onions and leave to cool slightly.
4. Place the spinach in a colander over the sink and pour over a kettle of boiling water. Refresh under cold water, then squeeze dry to remove all the excess water. Chop the spinach, put into a bowl, season and mix with the ricotta, then set aside.
5. On a lightly floured surface, roll out two-thirds of the pastry and use it to line the base and sides of a 23cm springform tin. Add half the spinach mixture in a layer, then distribute half the roasted squash on top of that. Scatter with half the pine nuts, then half the goat’s cheese. Repeat with the rest of the spinach mixture, butternut squash, pine nuts and goat’s cheese. Finally, add the garlicky onions in a layer on top.
6. On a lightly floured surface, roll out the rest of the pastry, then lay on top of the pie, pushing in the edges to seal well. Make a hole in the middle of the pie and decorate the top with leaves made from any leftover pastry. Brush the top of the pie with beaten egg, scatter with the rest of the Parmesan and chill for 20 minutes.
7. Cover with cling film and foil and freeze, uncooked, for up to 1 month.
8. When ready to eat, remove the foil and cling film and defrost fully in the fridge. Preheat the oven to 200°C/fan180°C/gas 6 and bake for 30-35 minutes until the pastry is golden brown on top. Leave to cool in the tin for 10 minutes before serving.
Per serving (based on 10): 564kcals, 32.2g fat (15.5g saturated), 19.6g protein, 52.3g carbs, 12.8g sugar, 1.1g salt.