Peel the potatoes and slice them into thin 1/8-inch rounds—I recommend using a mandoline for consistency, which ensures even cooking. Place the sliced potatoes in a bowl of cold water to prevent browning and remove excess starch. Finely dice the onion into 1/4-inch pieces and mince the garlic cloves. Preheat your oven to 400°F and lightly grease a 9x13 inch baking dish with a small amount of butter.
Melt 5 tablespoons of butter in a medium saucepan over medium heat. Add the diced onion and cook for 3-4 minutes, stirring occasionally, until softened and translucent. Add the minced garlic and cook for 1 minute more until fragrant. Sprinkle the flour over the mixture and stir constantly for 1-2 minutes to create a paste—this cooks out the raw flour taste and helps thicken the sauce. Gradually pour in the half-and-half while whisking continuously to avoid lumps. Add the salt, pepper, and ground nutmeg, then bring the mixture to a gentle boil, stirring frequently. I like to add the nutmeg here because it infuses into the cream beautifully and adds subtle depth without being obvious.
Drain the sliced potatoes from the cold water and pat them dry with paper towels—this removes the excess starch and helps them cook more evenly. Spread 1/3 of the potatoes in an even layer on the bottom of the greased baking dish. Pour 1/3 of the creamy sauce from Step 2 over the potatoes, distributing it evenly. Repeat this layering process twice more, ending with a final layer of sauce on top. I find that patting the potatoes dry makes a real difference in the final texture—it prevents a gummy layer from forming at the bottom.
Cover the baking dish tightly with aluminum foil and place it in the preheated 400°F oven. Bake covered for 30 minutes to gently cook the potatoes through while trapping steam. Remove the foil and bake for another 30 minutes until the top is golden brown and the potatoes are tender when pierced with a fork. The uncovered baking allows the top to brown slightly and any excess moisture to evaporate, creating a better texture throughout the dish.