01 - Preheat oven to 375°F. Grease a 9x13-inch baking dish with cooking spray or a light coating of olive oil.
02 - Bring a large pot of salted water to a rolling boil. Add ziti pasta and cook according to package directions until al dente. Drain well and set aside.
03 - Heat olive oil in a large skillet over medium heat. Add chopped onion and cook for 3 minutes until translucent. Add minced garlic and continue cooking for 1 minute until fragrant.
04 - Add ground beef to the skillet. Cook while breaking up the meat with a wooden spoon until fully browned and no pink remains. Drain excess fat from the skillet.
05 - Pour marinara sauce into the skillet with the browned beef. Add dried basil, oregano, salt, black pepper, and crushed red pepper flakes if using. Stir well and let simmer for 5 minutes to meld flavors.
06 - In a large mixing bowl, combine the cooked ziti, meat sauce, half of the mozzarella cheese, and all of the ricotta cheese. Fold together gently until pasta is evenly coated.
07 - Spread half of the pasta mixture into the prepared baking dish. Sprinkle with half of the remaining mozzarella and half of the Parmesan. Top with the remaining pasta, then finish with the rest of the mozzarella and Parmesan.
08 - Cover the baking dish tightly with aluminum foil. Bake for 20 minutes to heat through and melt the cheeses.
09 - Remove the foil and return to the oven for an additional 10 minutes, or until the 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.