01 - Preheat oven to 375°F. Lightly grease a 9x13-inch baking dish with cooking spray or olive oil.
02 - Bring a large pot of generously salted water to a rolling boil. Add ziti and cook according to package directions until al dente, typically 1-2 minutes less than recommended. Drain well and set aside.
03 - Heat olive oil in a large skillet over medium heat. Add chopped onion and sauté for 3 minutes until translucent and softened. Add minced garlic and cook for 1 additional minute until fragrant, being careful not to burn.
04 - Add ground beef to the skillet. Cook while breaking up with a wooden spoon or spatula until completely browned and no pink remains, approximately 7-8 minutes. Carefully drain excess fat from the skillet.
05 - Pour marinara sauce into the browned beef mixture. Add dried basil, oregano, salt, black pepper, and crushed red pepper flakes if using. Stir well to combine and let simmer for 5 minutes to allow flavors to meld.
06 - In a large mixing bowl, combine cooked ziti, meat sauce, half of the shredded mozzarella, and all of the ricotta cheese. Gently fold together until pasta is evenly coated.
07 - Spread half of the pasta mixture evenly across the prepared baking dish. Sprinkle with half of the remaining mozzarella and half of the Parmesan. Top with remaining pasta mixture, then finish with remaining mozzarella and Parmesan on top.
08 - Cover the baking dish tightly with aluminum foil. Bake for 20 minutes to heat through and allow flavors to develop.
09 - Remove foil and return to oven for an additional 10 minutes, or until cheese is golden brown and bubbling around the edges.
10 - Let the baked ziti rest for 10 minutes before serving. This allows the dish to set and makes serving easier.