The notion that the city would “build it back” when it came to thousands of homes damaged by Superstorm Sandy was always easier said than done.

But five years later, it’s clear that the city’s Build it Back program was a far more difficult undertaking than anyone anticipated. It was plagued with delays, bureaucratic hurdles, cost overruns and construction complications. Each neighborhood brought different challenges, like how to elevate a row of attached town houses in Staten Island, or how to get to dozens of Sheepshead Bay homes with no street access.

But as the fifth anniversary of the superstorm arrives Sunday, city officials finally have made progress. Construction has started on 99 percent of projects, while 87 percent of the 8,300 homeowners and landlords have seen work on their properties completed. Those statistics are even more significant when compared with a year ago, when just 63 percent of homes were finished.

But Build it Back can’t be called a success story. Created by Mayor Michael Bloomberg in 2013, the program promised assistance to any city resident who wanted it, including repairs, rebuilding, elevation or reimbursement. It sounded great, but was poorly executed. From the start, the city lacked the expertise, internal staffing and funds, and enough contractor manpower from the private sector to handle a task of this magnitude. Under Mayor Bill de Blasio, the program continued to suffer from high administrative and construction costs and delays. Ultimately, the program received nearly $2.2 billion in federal funds.

Only in the last year or two did city officials recognize the program’s failures and fix the problems. Now, the key is to learn from the program’s troubles. City officials said they hope to develop a road map for future post-storm recovery. They must, of course, finish the post-Sandy work, including the most complex Build it Back cases. But in the calm before the next storm, they also should look to other cities for new ideas and create a plan that will be ready for the stronger, more frequent storms that scientists say are coming.

Only then can NYC build it better.