Boil the pasta. Bring a large pot of salted water to a rolling boil.
Cook the ziti until very al dente—about 1 to 2 minutes less than package directions. Drain and set aside. Toss with a drizzle of olive oil to prevent sticking.
Start the sauce. Heat olive oil in a large skillet over medium heat.
Sauté onion until soft and translucent, about 5 minutes. Add garlic and cook 30 seconds, just until fragrant.
Add meat (if using). Stir in ground beef or sausage, breaking it up as it cooks. Season with salt and pepper.
Cook until browned and no longer pink. Spoon off excess fat if needed.
Simmer. Add crushed tomatoes, tomato paste, oregano, basil, red pepper flakes, and sugar if using. Bring to a gentle simmer.
Cook 10 to 15 minutes, stirring occasionally, until slightly thickened. Taste and adjust salt and pepper. You want a sauce that’s savory and bright, not heavy.
Mix the ricotta layer. In a bowl, combine ricotta, 1 cup mozzarella, 1/2 cup Parmesan, egg, chopped parsley, a pinch of salt, and a few grinds of pepper.
Stir until smooth and creamy.
Preheat and prep. Heat oven to 375°F (190°C). Lightly butter or oil a 9x13-inch baking dish.
Combine pasta and sauce. In a large bowl, toss the cooked ziti with about two-thirds of the tomato sauce. You want each piece coated but not drowning.
Reserve the remaining sauce for layering and topping.
Layer it up. Spread a spoonful of sauce in the baking dish. Add half the sauced pasta. Dollop half the ricotta mixture across the top in small spoonfuls (don’t spread completely).
Sprinkle with 1 cup mozzarella. Repeat with remaining pasta, remaining ricotta dollops, a few spoonfuls of sauce, and another 1 cup mozzarella.
Finish with cheese. Spoon the last of the sauce over the top in streaks. Sprinkle with the remaining mozzarella and the remaining Parmesan.
The top should be generously covered for that golden, bubbly finish.
Bake. Cover the dish loosely with foil, tenting it so it doesn’t stick to the cheese. Bake 20 minutes. Remove foil and bake another 10 to 15 minutes, until the top is melted, lightly browned, and bubbling around the edges.
Rest and serve. Let the baked ziti rest for 10 minutes before serving so it sets and slices cleanly.
Garnish with fresh parsley or basil. Serve with a crisp salad and garlic bread if you like.