01 - Preheat oven to 375°F. Lightly grease a 9x13 inch baking dish.
02 - Boil salted water in a large pot. Cook ziti until just al dente, about 2 minutes less than package instructions. Drain and set aside.
03 - Heat olive oil in a large skillet over medium heat. Cook onion until softened, about 3 minutes. Add garlic and sauté for 1 minute.
04 - Add ground beef to skillet. Brown thoroughly, breaking up meat until no pink remains. Drain excess fat.
05 - Stir in crushed tomatoes, tomato sauce, tomato paste, basil, oregano, thyme, red pepper flakes if using, sugar, salt, and pepper. Simmer uncovered for 10 minutes, stirring occasionally. Adjust seasoning as needed.
06 - In a medium bowl, mix ricotta cheese, egg, half the mozzarella (1 cup), and half the Parmesan cheese. Season with a pinch of salt and pepper until smooth.
07 - Add cooked ziti to meat sauce and toss to coat evenly.
08 - Spread half the pasta mixture in the baking dish. Layer half the ricotta mixture on top. Repeat with remaining pasta and ricotta mixtures.
09 - Sprinkle remaining mozzarella and Parmesan evenly over the assembled layers.
10 - Bake uncovered for 25 to 30 minutes until cheese is melted and golden. Allow to rest for 10 minutes before serving.
11 - Top with fresh basil or parsley if desired and serve warm.