Preheat and prep: Heat your oven to 375°F (190°C).
Grease a 9x13-inch baking dish with a light coating of olive oil or nonstick spray.
Cook the pasta: Bring a large pot of salted water to a boil. Add ziti and cook until 1–2 minutes shy of al dente. Drain and set aside.
Toss with a drizzle of olive oil to prevent sticking.
Make the sauce base: In a large skillet, warm 2 tablespoons olive oil over medium heat. Add onion and cook until soft and translucent, about 5 minutes. Stir in garlic for 30 seconds.
Brown the meat (if using): Add sausage or beef to the pan.
Cook, breaking it up with a spoon, until browned and cooked through. Drain excess fat if needed.
Simmer the sauce: Stir in marinara, crushed or diced tomatoes, oregano, basil, red pepper flakes, and a pinch of salt and pepper. Simmer for 10 minutes so the flavors come together.
Taste and adjust seasoning.
Mix the ricotta layer: In a bowl, combine ricotta, 1/2 cup Parmesan, and the egg (if using). Season with a pinch of salt and pepper. Stir until smooth.
Combine pasta and sauce: In a large bowl, toss the cooked ziti with about 2/3 of the sauce so it’s well coated but not soupy.
Layer in the dish: Add half the sauced ziti to the baking dish.
Spoon half the ricotta mixture over the pasta in dollops and lightly spread. Sprinkle with 1 cup mozzarella and a little Parmesan. Add the remaining ziti, dollop on the rest of the ricotta, and top with remaining sauce.
Finish with cheese: Sprinkle the top with the remaining 1 cup mozzarella and the rest of the Parmesan.
Bake: Cover loosely with foil (tent it so it doesn’t stick to the cheese) and bake for 20 minutes.
Remove the foil and bake another 10–15 minutes until bubbling and lightly browned on top.
Rest and serve: Let the baked ziti rest for 10 minutes so it sets and slices neatly. Garnish with chopped parsley or basil.