Caramelize the Onions: Heat the olive oil and butter in a large cast-iron skillet or Dutch oven over medium heat. Once hot, add the thinly sliced onions and cook for 5 minutes, stirring occasionally. Reduce the heat to low, add a pinch of salt, and continue cooking for 45 minutes to 1 hour, stirring occasionally, until the onions are deeply caramelized. Remove from the heat and allow them to cool completely, ideally overnight. Roast the Garlic: Preheat the oven to 400°F. Drizzle the trimmed head of garlic with a little olive oil and wrap it in aluminum foil or parchment paper. Bake for 40–45 minutes, until the garlic has softened. Allow it to cool, then squeeze the cloves out of their skins and set aside. Prepare the Baking Sheet: Line a baking sheet with parchment paper and set it aside.
Roll Out the Puff Pastry: Lightly flour a clean work surface. Roll the thawed puff pastry into a large rectangle measuring approximately 10 × 16 inches.Carefully transfer the pastry to the prepared baking sheet. Shape the Tart Base: Using a knife, lightly score a border about 1 inch from the edges of the pastry, taking care not to cut all the way through. Prick the pastry inside the border all over with a fork to help prevent excessive bubbling during baking. Preheat the Oven: Set the oven temperature to 375°F in preparation for baking the assembled tart.
Add the Gruyère Cheese: Sprinkle the shredded Gruyère evenly over the center of the puff pastry, keeping the scored border clear.
Add the Garlic, Onions, and Thyme: Distribute the roasted garlic cloves over the cheese.Arrange the cooled caramelized onions on top, then sprinkle with the fresh thyme leaves. Brush the Pastry Edges: Lightly brush the exposed pastry border with milk or egg wash to encourage a golden finish.
Bake the Tart: Bake at 375°F for 20 minutes. Increase the oven temperature to 400°F and continue baking for another 6–8 minutes, until the pastry edges are puffed, browned, and crisp.
Cool and Serve: Remove the tart from the oven and allow it to cool slightly before slicing. Serve warm.