01 - Preheat oven to 375°F. Grease a 9x13-inch baking dish with cooking spray or butter.
02 - Bring a large pot of salted water to a boil. Cook ziti according to package instructions until just al dente. Drain and set aside.
03 - Heat olive oil in a large skillet over medium heat. Add onion and cook for 3 minutes until softened. Add garlic and cook for 1 minute more until fragrant.
04 - Add ground beef to the skillet. Cook, breaking up the meat with a wooden spoon, until fully browned. Drain excess fat from the skillet.
05 - Stir in marinara sauce, dried basil, dried oregano, salt, black pepper, and crushed red pepper flakes if using. Simmer for 5 minutes to allow flavors to meld.
06 - In a large bowl, combine cooked ziti, meat sauce, half the mozzarella cheese, and all the ricotta cheese. Mix gently until evenly distributed.
07 - Transfer half the pasta mixture to the prepared baking dish. Sprinkle with half the remaining mozzarella and half the Parmesan. Layer the remaining pasta mixture on top, then finish with remaining mozzarella and Parmesan cheese.
08 - Cover the baking dish with aluminum foil and bake for 20 minutes.
09 - Remove foil and bake for another 10 minutes, or until cheese is golden brown and bubbling. Remove from oven and let rest for 10 minutes before serving to allow the dish to set.