Caramelize Onions: Start by melting butter and olive oil in a skillet over medium heat, then add thinly sliced onions along with salt and optional sugar to enhance caramelization. Stir occasionally until they turn golden brown and soft, about 20-25 minutes.
Prepare Potatoes: While the onions are cooking, wash and slice your Yukon Gold potatoes into ¼-inch thick rounds, ensuring they cook evenly in the oven.
Build Layers: Grease your baking dish with butter, then layer half of the sliced potatoes on the bottom followed by half of the caramelized onions, half of both cheeses, and some garlic powder and thyme.
Add Creamy Mixture: In a bowl, combine heavy cream or milk with additional salt and pepper before pouring half over the layered potatoes and onions in your baking dish for added creaminess.
Repeat Layers & Finish Topping: Repeat layering with remaining ingredients—potatoes, onions, cheeses—then pour remaining creamy mixture on top before finishing off with extra Parmesan cheese for that perfect golden crust.
Bake Until Golden Brown: Cover your baking dish with foil and bake at 375°F (190°C) for about 45 minutes, then remove foil and bake for another 15-20 minutes until bubbly and golden brown on top; let it rest before serving!