01 - Preheat the oven to 375°F. Lightly grease a 9x13-inch baking dish with cooking spray or a small amount of olive oil.
02 - Bring a large pot of salted water to a boil. Cook ziti pasta until just al dente according to package directions. Drain well and set aside.
03 - Heat olive oil in a large skillet over medium heat. Add chopped onion and sauté for 3–4 minutes until softened and translucent. Add minced garlic and cook for 1 minute until fragrant.
04 - Add ground beef to the skillet, breaking it up with a wooden spoon. Cook until browned and cooked through, about 5–6 minutes. Drain excess fat if necessary.
05 - Stir in marinara sauce, dried basil, dried oregano, red pepper flakes (if using), salt, and black pepper. Simmer the mixture for 5 minutes to allow flavors to meld.
06 - In a large mixing bowl, combine the drained ziti, beef and marinara mixture, ricotta cheese, and 1 cup of the shredded mozzarella. Mix gently until evenly coated.
07 - Transfer half of the pasta mixture to the prepared baking dish. Sprinkle with half of the remaining mozzarella and half of the Parmesan. Add the remaining pasta mixture, then top with the remaining mozzarella and Parmesan.
08 - Cover the baking dish with aluminum foil and bake for 20 minutes to heat through.
09 - Remove the foil and bake for an additional 10–15 minutes until the cheese is bubbly and lightly golden brown.
10 - Let the baked ziti stand for 10 minutes before serving to set. Garnish with fresh basil or parsley if desired.