01 - Preheat oven to 400°F. Grease a 9x13 inch baking dish with unsalted butter.
02 - Melt butter in a saucepan over medium heat. Add onion and garlic, and sauté for 3–4 minutes until softened and fragrant. Remove from heat.
03 - In a mixing bowl, whisk together heavy cream, whole milk, Cajun seasoning, smoked paprika, freshly ground black pepper, salt, and cayenne pepper if desired.
04 - Arrange half of the sweet potato slices evenly in the prepared dish, overlapping slightly. Top with half the sautéed onions and garlic, then sprinkle with half the Gruyère and Parmesan cheeses.
05 - Repeat the layering with remaining sweet potatoes, onions, and cheeses.
06 - Pour the cream mixture evenly over the layered ingredients. Gently press down so the liquid seeps between layers.
07 - Cover dish tightly with foil and bake for 30 minutes.
08 - Remove the foil and continue baking for an additional 15 minutes, until the top is golden and the sweet potatoes are tender.
09 - Let stand for 10 minutes before serving. Garnish with chopped parsley if desired.