Preheat the oven to 350°F. Spray a 9x9 baking dish with cooking spray, set aside.
Slice the potatoes very thin, 1/8th of an inch. I suggest using a mandolin for this. The potatoes need to be the same thickness so they all cook at the same time.
Place the sliced potatoes into a large bowl with cold water, set aside.
In a medium-sized skillet over medium-low heat, add the butter and melt. Add the onions, salt, and pepper, stirring occasionally cook until the onions are just softened, about 5 minutes.
Add the garlic and thyme, cook until fragrant, about 30 seconds.
Whisk in the flour and cook for 1 minute, slowly pour in the milk and whisk constantly to ensure no lumps form.
Whisk in the heavy cream. Stirring occasionally, let this mixture come to a simmer, once it starts to bubble the littlest bit, take it off the heat. Stir in half of the gouda until melted.
Drain the potatoes. Place half of the potatoes into the bottom of the baking dish.
Pour half of the cheese sauce on top. Sprinkle half of the parmesan cheese on top.
Add the rest of the potatoes on top. Top with the remaining sauce. Add the rest of the gouda and parmesan on top.
Bake covered with foil for 45 minutes then remove the foil and cook for about another 30 minutes (until the potatoes are fork-tender.)
Garnish with parsley, optional.
Video
Notes
Dried thyme can be substituted for the fresh thyme (about a teaspoon).