Preheat your oven to 375°F (190°C). Grease your baking dish with the room temperature butter to prevent sticking and add flavor.
In a mixing bowl, combine the heavy cream, quartered shallots, smashed garlic, fine sea salt, black pepper, and fresh thyme. Stir well to incorporate all the ingredients.
Using a sharp knife, slice the Yukon gold potatoes thinly—about 1/8 inch thick works best. You can also use a mandoline for even slices.
In the greased baking dish, begin layering the sliced potatoes. Pour a portion of the cream mixture over the first layer of potatoes. Sprinkle with half of the shredded Gruyere or sharp white cheddar cheese. Repeat the layering process until all the potatoes and cream mixture are used up, finishing with a layer of cheese on top.
Cover the baking dish with aluminum foil and place it in the preheated oven. Bake for about 45 minutes. After 45 minutes, remove the foil and continue baking for another 20-30 minutes, or until the top is golden brown and bubbly.
Once baked, remove the Potato Gratin from the oven and let it rest for about 10-15 minutes before serving.