01 -
Preheat oven to 350°F (175°C). Lightly grease a 9x13 or deep 9x9 baking dish with butter and set aside.
02 -
Heat olive oil in a medium skillet over medium heat. Add thinly sliced onions and season with salt and pepper. Cook, stirring occasionally, until caramelized and golden brown. Remove from skillet and set aside.
03 -
Wipe the skillet clean and cook bacon until crisp. Alternatively, bake bacon in the oven while onions cook. Remove bacon, drain excess grease, and set aside.
04 -
Melt butter in the same skillet over medium heat. Sprinkle flour over butter and whisk to combine. Cook the roux for 2 minutes.
05 -
Slowly pour in milk while whisking constantly. Bring to a simmer and cook until slightly thickened, about 2 to 3 minutes after reaching a simmer. Remove from heat and set aside.
06 -
Layer half the potatoes, half the caramelized onions, half the bacon, half the cheese, and half the sauce in the prepared baking dish. Repeat the layering process with the remaining ingredients.
07 -
Cover the baking dish with foil and bake for 1 hour. Remove foil and bake for an additional 30 minutes, or until potatoes are tender and easily pierced with a fork.
08 -
Remove the dish from the oven and let cool for 10 minutes before serving.