01 - Preheat oven to 375°F. Lightly grease a 9x13-inch baking dish.
02 - Boil ziti in salted water until just al dente. Drain and set aside.
03 - Heat olive oil in a large skillet over medium heat. Add chopped onion and cook until softened, about 3 minutes.
04 - Add minced garlic to the skillet and cook for 1 minute until fragrant.
05 - Add ground beef to the skillet, breaking it apart with a spoon. Cook until browned, 6 to 8 minutes, then drain excess fat.
06 - Stir marinara sauce, dried basil, oregano, salt, black pepper, and crushed red pepper flakes if using. Simmer for 5 minutes.
07 - In a large bowl, mix cooked ziti, meat sauce, ricotta cheese, and half of the shredded mozzarella and Parmesan until well combined.
08 - Spread half of the pasta mixture in the prepared baking dish. Top with half of the remaining mozzarella and Parmesan cheeses.
09 - Add the rest of the pasta mixture and sprinkle with the remaining mozzarella and Parmesan cheeses.
10 - Cover the dish with foil and bake for 20 minutes.
11 - Remove foil and bake for an additional 10 to 15 minutes until the cheese is melted and golden brown.
12 - Let the dish rest for 10 minutes before serving.