Walking can be the most cost-effective mode of transportation and the perfect exercise.

It can also be a death trap.

Which alternative depends on whether drivers and pedestrians are prudent and responsible, and how willing communities are to invest in infrastructure that make walking safe.

Maine had two of the deadliest years ever for pedestrians in 2015 and 2016, and 2017 is on a similar pace, with four deaths in the first two months of the year.

And national data that shows a sharp uptick in the number of people killed while walking give us more reason to be concerned. A report by the Governors Highway Safety Association released last week shows that the increase in pedestrian fatalities is outpacing the increase in motor vehicle crashes, after many years of decline in both categories.

The report does not pinpoint any specific cause for the change. Alcohol use among drivers and pedestrians may be a factor in many of the accidents. Distracted driving and walking may also be to blame in the smartphone era.

But the biggest cause for concern appears to be street design.

Most fatalities occurred at night, the study found. And most of the victims were not in crosswalks or even at intersections.

That might suggest that these were pedestrians who were making risky choices by being in places where they did not belong.

But what the report doesn’t say is whether there had been adequate lighting in those locations, or if there were passable sidewalks.

It’s likely that in both cases, the answer is no.

If lighting were not a problem, then there wouldn’t be more fatalities at night. If sidewalks had been available, few would risk walking in the street.

Maine should be taking these trends seriously and making sure its facilities are safe. The state Department of Transportation has endorsed the Complete Streets design standard – which makes motor vehicles share the road with bicycles and pedestrians in densely settled areas – but there are few places where it is fully implemented. This should be a priority.

There are many strong arguments for making streets safe for pedestrians, and no good reason to scrimp on investments.

Everybody saves money when people leave their cars at home and walk. There is less wear and tear on the roads, less traffic and easier parking.

It’s healthier for the people who choose to go by foot, and the healthier we are as a community, the lower our insurance costs will be. And people who don’t have cars, especially children and the elderly, deserve all the protection they can get.

The good news in these grim statistics is that more people appear to be walking. But it’s hard to celebrate when so many of them are dying.

Cities and towns should do all they can to make these life-saving improvements that reflect how people get around.