Preheat and prep. Heat the oven to 375°F (190°C).
Lightly oil a 9x13-inch baking dish.
Cook the pasta. Boil in well-salted water until very al dente, about 2 minutes less than package directions. Drain and set aside.
Make the sauce base. Warm olive oil in a large skillet over medium heat. Sauté onion with a pinch of salt until soft and translucent, 5–7 minutes.
Add garlic and cook 30 seconds.
Build the tomato sauce. Stir in crushed tomatoes, tomato paste (if using), oregano, basil, red pepper flakes, and a few grinds of black pepper. Simmer 8–10 minutes, stirring occasionally. Adjust salt to taste.
Add the greens. Fold in chopped spinach and cook until wilted, 1–2 minutes.
Turn off the heat.
Mix the ricotta layer. In a bowl, combine ricotta, 1 cup mozzarella, 1/4 cup Parmesan, the egg, and a pinch of salt and pepper. Stir until smooth.
Combine pasta and sauce. In a large bowl (or the sauce skillet if it’s big enough), toss the cooked pasta with the tomato-spinach sauce until evenly coated.
Layer in the dish. Spread half the sauced pasta into the baking dish. Dollop half the ricotta mixture over the top in spoonfuls.
Repeat with remaining pasta and ricotta.
Top with cheese. Sprinkle the remaining 1 cup mozzarella and 1/4 cup Parmesan evenly over the surface.
Bake. Cover loosely with foil (tent it so it doesn’t stick to the cheese) and bake 15 minutes. Remove foil and bake another 10–15 minutes, until the cheese is melted and browned in spots.
Rest and serve. Let the ziti rest 10 minutes so it sets. Garnish with chopped basil or parsley.
Serve warm.