Preheat the oven to 180°C (350°F).
Cook the pasta according to package instructions until al dente.
In a pan, heat olive oil and sauté the chopped onion and garlic until translucent.
Add the fresh spinach and cook until wilted. Season with salt and pepper.
In a bowl, mix the ricotta cheese with milk, salt, and pepper until smooth.
Combine the cooked pasta, spinach mixture, and ricotta mixture in a large bowl.
Transfer the mixture to a baking dish and spread it evenly.
Top with grated mozzarella and Parmesan cheese.
Bake in the preheated oven for 25-30 minutes, or until the cheese is golden and bubbly.
Let it cool for a few minutes before serving.