Preheat oven to 350°F. Butter a 9x13 inch baking dish.
Peel potatoes and slice to 1/8-inch thickness using a mandoline or sharp knife. Place slices in cold water as you work, then drain well and pat dry with paper towels.
In a large saucepan, melt butter over medium heat. Add diced onion and cook until soft and translucent, about 5 minutes. Add minced garlic and cook for 30 seconds more until fragrant.
Sprinkle flour over the onion mixture and stir constantly for 1-2 minutes to cook the flour.
Gradually whisk in the milk and cream, a little at a time, ensuring there are no lumps. Bring to a gentle simmer and cook, stirring constantly, until thickened enough to coat the back of a spoon, about 3-5 minutes.
Remove from heat and stir in 1 1/3 cups of the cheese mixture until melted. Add salt, pepper, thyme, and nutmeg. Taste and adjust seasonings if needed.
Layer one-third of the potatoes in the prepared baking dish, slightly overlapping. Pour one-third of the cheese sauce over the potatoes. Repeat two more times with remaining potatoes and sauce.
Sprinkle the remaining 2/3 cup cheese over the top. Cover tightly with aluminum foil.
Bake for 45 minutes, then remove foil and bake for an additional 30-40 minutes until potatoes are tender and top is golden brown and bubbling.
Allow to rest for 15 minutes before serving. Garnish with fresh parsley if desired.
Notes
For extra richness, you can substitute some of the milk with additional cream. If the top begins to brown too quickly during the uncovered baking time, loosely place the foil back on top.