Prepare the Filling:
Heat olive oil in a saucepan over medium heat. Sauté the onion and garlic until softened and fragrant.
Add the spinach and cook until wilted (if using fresh) or warmed through (if using frozen). Remove from heat and let cool slightly.
Stir in dill, beaten eggs, and feta cheese. Season with salt and pepper to taste.
Prepare the Phyllo Dough:
Preheat the oven to 375°F (190°C).
Lay the phyllo dough flat and cover it with a clean kitchen towel to prevent it from drying out.
Assemble the Spanakopita:
Brush the bottom and sides of a baking dish with melted butter.
Layer one sheet of phyllo dough in the dish, allowing the edges to hang over. Brush lightly with melted butter. Repeat this process with 8-10 sheets of phyllo.
Spread the spinach filling evenly over the phyllo.
Layer another 8-10 sheets of phyllo on top, brushing each layer with butter. Tuck the overhanging edges down into the dish.
Bake:
Use a sharp knife to score the top layer of phyllo into squares or diamond shapes.
Bake in the preheated oven for 40–45 minutes, or until the top is golden brown and crispy.
Cool and Serve:
Allow the Spanakopita to cool slightly before cutting and serving.