01 - Preheat the oven to 375°F. Grease a 9x13-inch baking dish.
02 - Bring a large pot of salted water to a boil. Cook the ziti until just al dente, about 7 to 8 minutes. Drain and set aside.
03 - Heat olive oil in a large skillet over medium heat. Add chopped onion and cook until softened, about 3 to 4 minutes. Stir in minced garlic and cook for 1 more minute.
04 - Add ground beef to the skillet. Cook, breaking it up, until browned and no longer pink, approximately 7 minutes. Drain excess fat if necessary.
05 - Stir in tomato paste, pasta sauce, dried oregano, dried basil, crushed red pepper flakes if using, and season with salt and black pepper. Simmer for 5 minutes to blend flavors.
06 - In a bowl, combine ricotta cheese with half the Parmesan cheese, adding a pinch of salt and black pepper to taste.
07 - Spread half of the cooked ziti in the prepared baking dish. Layer half of the meat sauce over the pasta, then dollop half of the ricotta mixture on top. Sprinkle with half of the mozzarella cheese.
08 - Add remaining ziti, top with remaining meat sauce, then the rest of the ricotta mixture. Finish by sprinkling with the remaining mozzarella and Parmesan cheeses.
09 - Cover the baking dish with foil and bake in the preheated oven for 25 minutes.
10 - Remove the foil and bake for an additional 10 to 15 minutes until the cheese is bubbly and golden brown.
11 - Let the dish rest for 10 minutes before serving. Garnish with fresh basil leaves if desired.