Preheat oven to 400°. Separate Swiss chard leaves and stems, and chop both into 1 inch pieces. Slice the peeled sweet potatoes into rounds about 1/8 inch thick.
Heat 2 Tablespoons of the butter in a large, heavy pot over medium-low heat, and cook the onion, stirring, until softened. Add chard stems (not greens), a pinch of nutmeg, salt and pepper, and cook, stirring often, until all the vegetables are tender but not browning, about 8 minutes.
Increase heat to medium-high and add chard leaves in batches, stirring often, until all the greens are wilted. Season lightly with salt and pepper and transfer everything to a colander in the sink to drain. Press with a spoon to release excess liquid.
Make the Béchamel sauce: In a small saucepan, combine milk or cream with garlic and bring to a simmer; keep warm. In a medium saucepan, melt the butter over low heat and stir in the flour to make a roux. Cook the roux, while whisking for about one minute, then slowly whisk in the warm milk or cream. Bring the sauce to a gentle simmer, whisking constantly, and cook about one minute, then remove from heat. Season with salt and pepper.
Butter a 9” x 13” baking dish. Spread half of the sliced sweet potatoes in the bottom of the dish. Sprinkle with salt, pepper, ¼ of the herbs and 1/4 of the cheese. Then add half the greens mixture, another ¼ of the herbs and 1/4 of the cheese.
Pour half the béchamel sauce over the first two layers, and then repeat the process with the remaining ingredients, topping the final layer with the last 1/4 of the cheese.
Bake the gratin for about 1 hour until golden and bubbly, and most of the liquid has been absorbed. Let stand for 10 minutes before serving.
Adapted from smittenkitchen.com