01 - Preheat oven to 375°F. Grease a 9x13-inch baking dish.
02 - Boil salted water and cook ziti until just al dente. Drain and set aside.
03 - Heat olive oil in a large skillet over medium heat. Sauté onion for 3–4 minutes until softened, then add garlic and cook for 1 minute.
04 - Add crushed tomatoes, tomato sauce, oregano, basil, red pepper flakes, salt, and black pepper. Simmer for 10–15 minutes, stirring occasionally.
05 - In a bowl, mix ricotta, egg, half the Parmesan, half the mozzarella, and parsley if using until smooth.
06 - Spread 1 cup of tomato sauce on the baking dish bottom. Layer half of the cooked pasta over the sauce, dot half of the ricotta mixture, pour half of the remaining sauce, and sprinkle with one-third of the remaining mozzarella.
07 - Repeat layering with remaining pasta, ricotta mixture, sauce, and mozzarella. Top with the remaining Parmesan cheese.
08 - Cover the dish with foil and bake for 25 minutes.
09 - Remove the foil and bake for an additional 15 minutes until cheese is bubbly and golden.
10 - Allow to rest for 10 minutes before serving. Garnish with fresh herbs if desired.