Preheat the oven to 375°F
Grease a baking dish
Peel and thinly slice potatoes
Melt butter in a saucepan
Add flour and cook briefly
Whisk in milk or cream until smooth
Stir in salt, pepper, and garlic if desired
Add shredded cheese and stir until melted
Layer potatoes in the baking dish
Pour the cheese sauce over the potatoes
Repeat layers if needed
Cover with foil
Bake until potatoes are tender
Remove foil and bake until the top is golden
Let rest before serving
