Follow the steps in order for the best result.
To prepare the creamy gratin sauce, begin by melting butter in a small saucepan over medium heat. Incorporate the flour, stirring continuously for about one minute until smooth.
Gradually whisk in the milk, ensuring there are no lumps. Continue to stir until the sauce thickens to your liking. Stir in the cheddar cheese until melted and smooth. Remove from heat and season with salt and pepper to taste.
In a separate frying pan, heat the olive oil over medium heat. Add the sliced shallots and sauté until they turn a golden-brown color and become caramelized. Remove the shallots from the pan and set aside.
Place the bacon slices in the same skillet and cook until done but not crispy. Remove from the pan and cut into approximately one-inch pieces.
Grease a gratin dish or shallow baking dish to prevent sticking. Arrange half of the sliced purple potatoes in an even layer. Sprinkle the sautéed shallots evenly over the potatoes, then top with the remaining potato slices.
Pour the prepared gratin sauce over the potatoes, making sure to spoon the sauce into any visible cracks and crevices to ensure even distribution. Sprinkle the grated Parmesan cheese evenly over the top, followed by the bacon pieces.
Bake in a preheated oven at 350 degrees Fahrenheit for approximately 40 minutes, or until the potatoes are tender and the top is golden brown and bubbly. Let stand for a few minutes before serving.
Serve immediately as a flavorful side dish or comforting main course.