Step 1: Cook the Pasta : Bring a large pot of salted water to a boil. Add ziti pasta and cook until just al dente (1–2 minutes less than package instructions). Drain and toss lightly with a drizzle of olive oil to prevent sticking. Set aside.
Step 2: Prepare the Meat Sauce : In a large skillet or saucepan, heat olive oil over medium heat. Add chopped onion and cook for 3–4 minutes until soft. Add minced garlic and cook for another 30 seconds. Add ground beef and cook until browned, breaking it up with a spoon, about 6–8 minutes. Drain excess fat if needed. Stir in marinara sauce, tomato sauce (if using), oregano, basil, red pepper flakes, salt, and pepper. Simmer on low heat for 10–15 minutes to allow flavors to meld.
Step 3: Prepare the Cheese Mixture : In a medium bowl, combine ricotta cheese, 1 cup mozzarella, ¼ cup Parmesan, egg (if using), and parsley. Stir until smooth and creamy.
Step 4: Assemble the Baked Ziti : Preheat oven to 375°F (190°C). Grease a 9x13-inch baking dish with butter or oil. Spread a thin layer of meat sauce on the bottom of the dish. Layer half of the cooked ziti over the sauce. Spoon half of the ricotta mixture over the pasta and spread evenly. Add half of the remaining sauce and sprinkle with a handful of mozzarella. Repeat layers with the remaining ziti, ricotta mixture, sauce, and cheese. Top with the reserved mozzarella and Parmesan.
Step 5: Bake : Cover with aluminum foil and bake for 20 minutes. Remove foil and bake for an additional 15–20 minutes, until the top is golden and bubbly. Let rest for 10–15 minutes before serving — this helps the layers set beautifully.