Preheat oven to 350°F. Grease a 9x13-inch baking pan with butter.
Layer the potatoes and onions in the baking dish. Set aside.
3 pounds Yukon Gold potatoes, ½ yellow onion
In a medium saucepan, melt the butter over medium heat. Add in the garlic and cook until fragrant.
4 tablespoons unsalted butter, 2 cloves garlic
Sprinkle over the flour and whisk until smooth and the flour is golden, about 1 minute.
¼ cup all-purpose flour
Slowly pour in the milk while whisking, making sure to quickly whisk out any lumps. Bring to a simmer.
1½ cups whole milk
Remove from the heat and whisk in the salt, pepper, cheddar, and ¾ cup gruyere until melted. Pour over the potatoes.
1 teaspoon kosher salt, ½ teaspoon ground black pepper, 1 cup freshly shredded cheddar cheese, 1½ cups freshly shredded gruyere cheese
Cover with foil and bake for 45-60 minutes, or until the potatoes are tender when pierced with a knife in the center of the baking dish.
Remove the foil and sprinkle on the remaining gruyere and parmesan cheese. Bake for 15-20 minutes until the cheese is melted and bubbly.
½ cup freshly grated Parmesan cheese
Optional: To brown the cheese, broil for 1-2 minutes.
Garnish with herbs and serve.