1Preheat the oven to 375°F and spray a 9-inch square baking dish with cooking spray.
2Slice potatoes into 1/8-inch-thick rounds.
3Place potatoes in the baking dish in rows, ensuring they are slightly slanted and not packed too tightly. Insert onion slices between and on top of the potatoes.
4In a medium pot, melt butter over medium heat. Whisk in flour and cook until a paste forms, about 30 seconds. Slowly stream in milk while whisking constantly until smooth.
5Raise heat to medium-high to bring to a boil, then reduce to medium-low and simmer until thickened to a creamy gravy consistency, about 5 minutes.
6Reduce heat to low and stir in the Cheddar, salt, garlic powder, and black pepper. Taste and adjust seasoning if needed.
7Pour the sauce evenly over the potatoes and onions and cover the pan with foil.
8Bake the potatoes for 45 minutes.
9Remove the foil, sprinkle with Gruyére and Parmesan, and bake uncovered until potatoes are tender and the top is golden brown, 30 to 45 minutes.
10Cool for 10 minutes, then top with fresh herbs and serve.