Preheat the Oven: Preheat your oven to 200°C (fan 180°C, gas mark 6).
Sauté Onions and Garlic: In a skillet, melt a knob of butter over medium heat. Add the chopped onions and sauté for 5-7 minutes until softened. Add the minced garlic and fresh rosemary, cooking for another minute until fragrant. Remove from heat.
Prepare the Cream Mixture: In a large mixing bowl, combine the cream, milk, and crème fraîche. Season with salt and black pepper.
Combine Potatoes and Onion Mixture: Add the thinly sliced potatoes and the sautéed onion mixture to the cream mixture, stirring gently to coat the potatoes evenly.
Layer the Gratin: Grease a small ovenproof dish with butter. Layer half of the potato mixture in the dish, then sprinkle half of the grated cheese on top. Repeat with the remaining potato mixture and top with the remaining cheese.
Bake: Cover the dish with foil and bake in the preheated oven for 1 hour. After an hour, remove the foil and bake for an additional 15-30 minutes, or until the potatoes are tender and the top is golden brown.
Serve: Allow the gratin to cool for a few minutes before serving. Enjoy it as a delicious side dish or a comforting main!