San Francisco, Oakland and Berkeley take pride in their progressive values. But all three cities maintain land-use laws that are exclusionary. Each bars new apartments from being built in many neighborhoods, effectively pricing out a new generation of working and middle-class families. How could this happen?

Why are progressive cities denying teachers, nurses, janitors and firefighters the ability to live in the cities where they work? Defenders of exclusionary land-use laws insist that the upscale transformation of affordable urban neighborhoods was “inevitable.” Instead of targeting local governments for this result, they cite the Bay Area’s desirable climate, high-paying jobs and homes with sweeping bay views. But the Bay Area also enjoyed such attractions in the far more affordable 1970s and 1980s.

Prices skyrocketed in recent decades because of the longtime failure of all three cities to build enough housing to meet population and job growth. There was nothing “inevitable” about this decision to stop building housing. Instead, it was driven by homeowners insisting that “neighborhood preservation” required banning new apartments. That their neighborhoods already had apartments made no difference; homeowners recast plans for new multiunit buildings as an assault on neighborhood “character.”

Homeowners also won the power to file multiple appeals of proposed development projects. New housing must overcome a series of public approval hearings held before homeowner-dominated bodies whose members profit by restricting housing supply. This combination of banning new apartments and a lengthy and uncertain approval process has allowed longtime homeowners to make out like bandits: Over the past six years, the average single-family homeowner in San Francisco has seen its equity increase by $1 million. That’s $13,125 a month, every month for six straight years. All at the expense of working and middle-class Millennials who cannot afford to live in most neighborhoods.

Fortunately, land-use policies got us into this affordability mess, and new policies can get us out. Here’s what cities must do:

•Legalize new apartments in all residential neighborhoods. It makes no sense that in vast stretches of San Francisco’s west side it is legal to build a four-story mansion but not a fourplex. Yet that is what the current zoning provides.

•Stop giving veto power over new housing to economically self-interested homeowners. Both Berkeley and San Francisco require project approval from multiple public bodies even when the housing completely complies with local zoning. San Francisco even allows any member of the public to delay projects by paying $617 to obtain “discretionary review” over a for-profit development (and fee waivers are available). Berkeley’s City Council twice rejected a three-unit project on a site zoned for four units, the second rejection coming despite a court effectively ordering it approved. Seattle and Denver avoid these lengthy public approval projects and build housing more than twice as fast as San Francisco.

•Raise heights and density along transit corridors. That means upzoning College and Claremont avenues near Oakland’s Rockridge BART Station and along Berkeley’s University and San Pablo avenues. By granting builders density bonuses in exchange for expanding affordability, both cities could add hundreds if not thousands of new housing units simply by matching the standard building heights of Paris, Vienna and other great cities.

San Francisco, Berkeley and Oakland have some of the nation’s strongest tenant and rental housing protections. And these cities must do everything in their power to stop the displacement of long-term tenants paying below-market rents. But focusing exclusively on protecting existing residents addresses only part of the problem. It does not address the housing needs of a Millennial generation of working and middle-class families seeking to live in these cities. This requires increasing housing supply and using inclusionary housing to create entry points for working and middle-class families otherwise priced out of affluent neighborhoods.

Having run housing programs for homeless persons for 30 years and having represented low-income tenants for even longer, I am well aware that building new housing does not address the major segment of the Bay Area rental market that cannot obtain housing without government subsidies. The federal government’s sharp reduction in such assistance since the late 1970s explains why we have so many homeless persons on San Francisco, Oakland and Berkeley streets.

But the federal government’s failure to house the very poor does not excuse cities from doing their best to create housing options for the working and middle class. It is even more imperative that cities build infill housing that avoids workers needing long car commutes the produce climate-changing gases. Boomer homeowners think they are doing their part for the environment by recycling and driving Priuses, but by opposing housing in their neighborhoods they are promoting sprawl and contributing to climate change.

I’ve talked with people in more than a dozen cities, and I know we can stop the pricing out of the working and middle class. It is a question of political will.

Randy Shaw’s new book is “Generation Priced Out: Who Gets to Live in the New Urban America” (University of California Press, 2018). To comment, submit your letter to the editor at SFChronicle.com/letters.