Prep Your Oven & Pastry: Preheat your oven to 190°C (170°C fan/Gas Mark 5). Grab your favorite 23cm tart tin. If you're using puff pastry, just unroll it and gently press it into the tin, trimming off any big excess. For shortcrust, you'll roll it out a bit first, then line the tin. Give the base a little prick all over with a fork – this helps prevent it puffing up too much. Depending on your pastry package instructions, you might need to do a quick blind bake here (lining it with parchment and filling with baking beans/rice for a bit, then removing them). I sometimes skip the blind bake with good quality puff pastry if I'm feeling lazy, but follow the package if it recommends it!
Caramelize Those Onions: This is the most important step for flavor! Heat the butter and olive oil in a large pan over medium-low heat. Toss in your thinly sliced onions. Now, this is where patience comes in. Cook them slowly for 20-30 minutes, stirring occasionally. You want them to soften, turn sweet, and develop a deep golden-brown color. Don't rush this part – it's worth the wait!
Sauté the Mushrooms: While the onions are doing their thing in the background, get a separate pan going over medium-high heat. Add your sliced mushrooms and cook, stirring. They'll release their liquid first, and then start to brown up nicely, about 5-7 minutes. You want them cooked down a bit.
Combine the Filling: In a bowl, mix together your gorgeous caramelized onions, the cooked mushrooms, the grated Gruyere cheese, and those fresh thyme leaves if you're using them. Give it a good season with salt and pepper. Taste a little bit! Does it need more salt?
Fill the Pastry: Spread this yummy onion and mushroom mixture evenly over the base of your prepared pastry shell in the tart tin.
Whip Up the Custard: Grab a jug (makes pouring easy!) and whisk together the eggs, cream, milk, and another little pinch of salt and pepper. Get it all nice and combined.
Pour and Bake: Carefully pour the egg mixture all over the filling in the tart shell. Make sure it gets into all the little nooks and crannies. Pop the tart into your preheated oven. Bake for 25-35 minutes. You'll know it's done when the filling is set (it won't jiggle too much in the center) and the top is beautifully golden brown.
Cool Slightly: Once it's out of the oven, resist the urge to slice immediately! Let the tart cool in the tin for 5-10 minutes. This helps it set up properly so it doesn't fall apart when you cut into it.
Serve and Enjoy! Slice it up and serve warm. It's perfect on its own or with a simple green salad.