Preheat the oven to 375°F. Grease a 9x13-inch baking dish with cooking spray or olive oil.
In a large bowl, combine the cubed butternut squash, diced onion, minced garlic, cinnamon, nutmeg, salt, and pepper. Drizzle with olive oil and toss until everything is well coated.
Transfer the mixture to the prepared baking dish and spread it out evenly. Bake in the preheated oven for 30 minutes, or until the squash is tender.
Remove the dish from the oven and sprinkle the cheddar cheese and half of the Parmesan cheese over the top. If using breadcrumbs, sprinkle them evenly over the cheese layer.
Return the dish to the oven and bake for an additional 15 minutes, or until the cheese is melted and bubbly.
Remove from the oven and let it cool for a few minutes. Garnish with the remaining Parmesan cheese and chopped parsley before serving.