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 skillet over medium heat. Sauté onion until softened, about 3 minutes.
04 - Add minced garlic to the skillet and cook for 1 minute until fragrant.
05 - Add ground beef to skillet, breaking it up with a spoon. Cook until browned, 6–8 minutes. Drain excess fat.
06 - Stir in marinara sauce, dried basil, oregano, salt, black pepper, and optional red pepper flakes. Simmer for 5 minutes.
07 - In a large bowl, mix cooked ziti, meat sauce, ricotta, and half of the mozzarella and Parmesan until evenly combined.
08 - Spread half the pasta mixture into the baking dish. Top with half the remaining mozzarella and Parmesan cheeses.
09 - Layer the remaining pasta mixture on top, then sprinkle with the rest of the mozzarella and Parmesan.
10 - Cover dish with foil and bake for 20 minutes.
11 - Remove foil and bake an additional 10 to 15 minutes until cheese is melted and golden brown.
12 - Allow to rest for 10 minutes prior to serving.