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