01 - Preheat your oven to 375°F (190°C). Lightly grease a 9x13 inch (23x33 cm) baking dish.
02 - Boil the pasta in well-salted water for 2 minutes less than the package instructions recommend. Drain thoroughly and set aside.
03 - In a saucepan, melt the butter over medium heat. Add the chopped onion and cook until softened, approximately 4 minutes. Stir in the minced garlic and chopped sage, and cook for an additional minute.
04 - Sprinkle the flour over the sautéed aromatics and stir for 1 minute. Gradually whisk in the milk and heavy cream. Bring the mixture to a gentle simmer, stirring constantly until it thickens, about 5 minutes.
05 - Season the thickened sauce with nutmeg, salt, and pepper. Remove from heat. Stir in half of the Gruyère and half of the Parmesan cheese until fully melted and the sauce is smooth.
06 - In the prepared baking dish, arrange half of the sweet potato slices, followed by half of the cooked pasta. Evenly distribute half of the cheese sauce over this layer. Repeat the layering process with the remaining sweet potatoes, pasta, and sauce.
07 - Evenly sprinkle the remaining Gruyère and Parmesan cheeses over the top of the assembled gratin.
08 - In a small bowl, combine the fresh breadcrumbs with olive oil and parsley (if using). Scatter this mixture uniformly over the gratin.
09 - Cover the baking dish tightly with foil and bake for 25 minutes. Remove the foil and continue baking for an additional 15–20 minutes, or until the gratin is golden brown and bubbling.
10 - Allow the gratin to rest for 10 minutes before serving to allow the flavors to meld and the structure to set.