Preheat and prep: Heat your oven to 375°F (190°C). Lightly grease a 9x13-inch baking dish.
Cook the pasta: Bring a large pot of salted water to a boil.
Cook ziti until just shy of al dente—about 1–2 minutes less than package directions. Drain and set aside.
Sauté aromatics: In a large skillet, warm olive oil over medium heat. Add the diced onion with a pinch of salt and cook until soft and translucent, 4–5 minutes.
Stir in the garlic and cook 30 seconds, until fragrant.
Brown the beef: Add ground beef to the skillet. Season with salt, pepper, Italian seasoning, and red pepper flakes if using. Cook, breaking it up with a spoon, until browned and no pink remains.
If needed, drain excess fat.
Add the sauce: Pour in about 3 to 3 1/2 cups of marinara. Simmer for 5 minutes to meld flavors. Taste and adjust salt and pepper.
You’ll use any remaining sauce to layer and moisten the top.
Make the ricotta mixture: In a bowl, stir together ricotta, 1 cup shredded mozzarella, Parmesan, the egg, a pinch of salt, and a few grinds of pepper. Mix until smooth.
Combine with pasta: In a large mixing bowl, add cooked ziti and the beef-sauce mixture. Fold gently to coat the pasta without breaking it.
Layer in the baking dish: Spread a thin layer of plain marinara (a few spoonfuls) on the bottom.
Add half the pasta mixture, dollop and spread half the ricotta mixture over it, then sprinkle with about 1 cup mozzarella. Repeat with remaining pasta, remaining ricotta, and another 1 cup mozzarella. Spoon a little extra marinara over the top if it looks dry.
Bake: Cover tightly with foil and bake for 20 minutes.
Remove foil and bake another 10–15 minutes, until the cheese is melted and lightly golden with some bubbling around the edges.
Rest and serve: Let the baked ziti rest for 10 minutes so it sets. Sprinkle with chopped basil or parsley if you like. Serve warm.