01 - Preheat the oven to 375°F. Grease a 9x13-inch baking dish with butter or cooking spray.
02 - Bring a large pot of salted water to a boil. Cook ziti until al dente according to package directions. Drain and set aside.
03 - Heat olive oil in a large skillet over medium heat. Add ground beef and cook, breaking up with a spoon, until browned and cooked through.
04 - Add chopped onion to the skillet and cook for 3 to 4 minutes until softened. Stir in minced garlic and cook for another minute.
05 - Pour in crushed tomatoes, tomato sauce, and tomato paste. Stir in oregano, basil, crushed red pepper flakes if using, salt, black pepper, and sugar. Let simmer for 10 to 15 minutes, stirring occasionally.
06 - In a medium bowl, combine ricotta cheese, egg, and half of the grated parmesan cheese until well mixed.
07 - Add the cooked ziti to the skillet with the meat sauce and toss until evenly coated.
08 - Spread half of the sauced pasta into the prepared baking dish. Spoon half of the ricotta mixture over the pasta and sprinkle with 1 cup of mozzarella. Repeat layering with remaining pasta, ricotta, and mozzarella. Top with remaining parmesan cheese.
09 - Cover the dish with aluminum foil and bake for 20 minutes. Remove foil and continue baking for an additional 10 to 15 minutes until cheese is melted and golden.
10 - Allow to cool for 10 minutes before serving. Garnish with fresh parsley or basil if desired.