Preheat oven to 350°F (175°C). Grease a 9×13 inch baking dish.
Peel and thinly slice Yukon Gold potatoes, placing them in cold water to prevent browning. Slice the onion and mince the garlic.
In a saucepan, melt butter over medium heat, whisk in flour for about 2-3 minutes until a roux forms. Gradually add milk and cream, stirring to avoid lumps.
Season with salt, pepper, and nutmeg; simmer until thickened (5-7 minutes). Stir in cheeses until melted.
Drain potato slices and pat dry. Layer one-third of potatoes, onions, and sauce in the baking dish; repeat twice more.
Top with remaining sauce and sprinkle with reserved cheese.
Cover with foil and bake for 1 hour; uncover and bake for another 30-45 minutes until golden brown. Let rest for at least 15 minutes before serving.