I don’t think it can really be done. If a community is nicer, the cost of living will go up, rents will raise, and the housing prices will go up. This is natural. Nothing you can do about it without deliberately making the place worse to live. You can hedge your bets by owning your property, but you must live with the consequences of owning if your neighborhood never gets any nicer. When you rent, don’t assume that your landlord has any obligation to keep your rent lower just because you’ve always lived there.
I think that the only way to truly eliminate gentrification, but continuously improve our communities is to attack income inequality and “grow the pie.” If 80% of the country lived within one standard deviation of the median income and net wealth, this wouldn’t be an issue. Well over half of the country would all live in great communities, great housing, and have access to great education and work.
When you have a small percentage of the country holding so much wealth, and the bottom half of the country fighting over the scraps, these problems are exacerbated.