Preheat the oven to 400℉/207℃. Grease a 12-inch cast iron skillet or 11- to 12-inch oval or round baking dish with butter and set aside.
Peel and trim the butternut squash. Slice the squash in half where the top meets the base. Cut the base in half lengthwise and scoop out the seeds. Use a mandoline or very sharp knife to slice the squash pieces into thin disks. If you are using a knife, make sure the disks are ⅛-inch thick or thinner.The slices from the top portion of the squash will be perfect circles, but the slices from the halved base will be half-circles. You can tuck the half-circles into the bottom layers of the gratin and use the full circles where they'll be visible on top if desired. Prepare the gratin sauce. Warm 2 tablespoons of the olive oil in a medium skillet over medium heat. Add the diced shallots and cook for a few minutes until lightly browned. Add the garlic and cook for a minute until fragrant. Stir in the rest of the olive oil, thyme, butter, ½ cup of vegetable broth, pepper, and salt. Cook until the butter is melted. Remove from heat.
In a small bowl, stir together the chopped walnuts, brown sugar, and nutmeg. Prepare the grated cheeses.
Layer the gratin. First, pour the the remaining ¼ cup of broth into the bottom of the greased pan. Next, make a layer of butternut squash slices by overlapping them like shingles. Drizzle about ⅓ of the olive oil sauce over the first layer of squash. Sprinkle ⅓ of the walnut brown sugar mixture on top, followed by ⅓ of each the gruyere and parmesan cheeses.
Repeat the process two times, each with another layer of squash, ⅓ of the olive oil sauce, ⅓ of the walnut brown sugar mixture, and ⅓ of the cheeses.
Cover the pan tightly with aluminum foil. Place it on the center rack of the preheated oven. Cook for 35 to 45 minutes until the squash is tender and browned around the edges and the cheese is melted. Remove the foil and bake for another 5 to 10 minutes until browned to your liking (if you want it more browned; this step is optional). Be careful not to cook it for too long with the foil removed so that the walnuts don't burn.
Scoop onto dishes and enjoy!
Leave a rating or review by tapping the stars on this recipe card (above) or in the comments section (at the end of the post)!