Preheat your oven to 375°F (190°C). Lightly grease a shallow baking dish with a little butter or oil to prevent sticking.
In a small saucepan, warm the cream with the butter, garlic, sage, salt, and pepper. Let it simmer just to bloom the flavors, then remove from heat. If you like a more pronounced sage flavor, you can steep the sage for a few minutes before straining it out.
Line the bottom of the dish with a thin layer of sliced sweet potatoes. Top with a sprinkle of onions and a light pinch of salt. Repeat the layers until you run out of ingredients, finishing with a layer of potatoes on top.
Pour the warm cream mixture over the layered potatoes. The liquid should come up to about halfway up the sides of the potatoes. If needed, you can add a splash more cream or a little stock to reach the right level.
Sprinkle the grated cheese evenly over the top. If you like a little golden crust, you can dot the surface with a tiny bit more butter.
Cover the dish with foil and bake for 30 minutes. Remove the foil and continue baking for another 25 to 30 minutes, until the potatoes are tender when pierced with a knife and the top is lightly browned and bubbling.
Let the dish rest for 5 to 10 minutes before serving. This helps the sauce set a little and makes scooping easier.