01 - Preheat oven to 400°F. Grease a 9x13 inch baking dish with butter.
02 - In a small saucepan over medium heat, melt the butter. Add sliced onion and minced garlic; sauté for 3 to 4 minutes until softened and fragrant. Remove from heat.
03 - In a mixing bowl, whisk together heavy cream, whole milk, Cajun seasoning, smoked paprika, black pepper, salt, and cayenne pepper if using.
04 - Arrange half of the sweet potato slices in the prepared baking dish, overlapping slightly.
05 - Spread half of the sautéed onions and garlic over the sweet potatoes. Sprinkle with half of the Gruyère and Parmesan cheeses.
06 - Top with remaining sweet potatoes, onions, and cheeses.
07 - Pour the seasoned cream mixture evenly over the layered ingredients. Press down gently so the cream penetrates all layers.
08 - Cover the dish tightly with foil and bake for 30 minutes.
09 - Remove foil and bake for an additional 15 minutes, or until the top is golden brown and sweet potatoes are tender.
10 - Let stand for 10 minutes after baking. Garnish with fresh parsley if desired before serving.