01 - Preheat oven to 375°F. Grease a 9x13 inch baking dish with butter or cooking spray.
02 - Cook ziti pasta in a large pot of salted boiling water until just al dente, about 2 minutes less than package instructions. Drain and set aside.
03 - Heat olive oil in a large skillet over medium heat. Add chopped onion and cook until softened, approximately 3 to 4 minutes. Stir in garlic and cook for 1 minute more.
04 - Add ground beef to the skillet, breaking it apart with a spoon while cooking until browned and cooked through. Drain excess fat if necessary.
05 - Stir in crushed tomatoes, tomato sauce, tomato paste, oregano, basil, red pepper flakes if using, salt, and pepper. Simmer for 10 minutes, stirring occasionally.
06 - In a large bowl, combine cooked ziti, half of the meat sauce, ricotta cheese, and half of the mozzarella and Parmesan cheeses. Mix gently until combined.
07 - Spread half of the remaining meat sauce in the prepared baking dish. Add the ziti mixture on top. Spread remaining sauce evenly over the pasta. Sprinkle with remaining mozzarella and Parmesan cheeses.
08 - Cover with aluminum foil and bake for 20 minutes. Remove foil and bake for an additional 10 to 15 minutes until cheese is golden and bubbly.
09 - Let rest for 10 minutes before serving. Garnish with fresh basil if desired.