Preheat the Oven:
o Preheat your oven to 375°F (190°C).
o Coat a 9x13-inch baking dish with butter or a non-stick spray to prevent sticking.
Prepare the Cream Sauce:
o In a medium saucepan, melt the butter over medium heat.
o Add the finely diced onion and cook until softened, about 4-5 minutes.
o Add the minced garlic and thyme, and cook for another minute until fragrant.
Make the Roux:
o Dust the onions and garlic with flour, ensuring an even coating.
o Stir well to combine, cooking for about 1 minute until the flour turns a light golden color.
Add the Milk:
o Slowly add the milk while continuously whisking to avoid any lumps.
o Keep cooking the sauce, stirring often, until it reaches a thicker consistency, which should take around 3 to 4 minutes.
Incorporate the Cheese:
o Reduce the heat to low and slowly add the shredded Gruyère cheese to the sauce, stirring until the cheese is melted and the sauce is smooth.
o Incorporate a dash of nutmeg (if desired) and adjust the flavor with salt and pepper to your liking.
o Remove from heat.
Layer the Potatoes:
o Arrange half of the sliced potatoes evenly in the prepared baking dish.
o Drizzle half of the cheese sauce over the potatoes, ensuring it is distributed uniformly.
o Layer the remaining potatoes on top, and finish by pouring the rest of the cheese sauce over them, making sure all the potatoes are covered.
Bake:
o Cover the dish with aluminum foil and bake in the preheated oven for 30 minutes. Remove the foil and continue baking for an additional 30-40 minutes, or until the potatoes are tender and the top is golden brown and bubbling.
Rest and Serve:
o Let the Potato Gratin rest for 10 minutes before serving to allow the sauce to set. Serve warm as a delicious side dish with your favorite main course.