01 - Preheat oven to 375°F. Rub a large baking dish with the cut sides of the garlic clove, then grease with 1 tbsp butter.
02 - Arrange half the sliced potatoes in the dish, overlapping slightly. Top with half the onions if using, and season with salt, pepper, and nutmeg.
03 - Sprinkle half the grated Gruyère evenly over the potatoes.
04 - Repeat layers with remaining potatoes, onions, seasoning, and cheese, ensuring cheese forms the final top layer.
05 - Gently heat cream and milk in a saucepan until just steaming but not boiling. Pour evenly over the layered potatoes. Dot surface with remaining 1 tbsp butter.
06 - Cover dish with aluminum foil and bake for 40 minutes.
07 - Remove foil and continue baking for 20 minutes until potatoes are tender and the top is golden brown and bubbling.
08 - Let rest for 10 minutes before serving. Garnish with chopped chives or parsley if desired.