Environmentalists advise us against chemical fertilizers and tell us to use organic alternatives instead. Sri Lanka tried to do that, and now its economy is in a total shambles (not only because of that, but partly because of that): they had crop failures and were forced to buy food from abroad, depleting foreign reserves. It also hurt the country's tea and rubber exports. Is it really such a good idea after all?
Recycling. Processing sewage is most effective means recovering rebuilding fertilizer use. Human reuse of excreta is thousands of Yeats old.
China, Japan, Korea did so, China in particular did so foe four millennia. Collapse of Rome eliminated sewers as method of waste disposal for centuries, unlike Medieval Europe where waterborne diseases proliferated due to collapse post Roman hygiene. China's waters were drinkable up until 19th-20th century. Documented in RF Kings book,"Farmers for Forty Centuries "
Organic fertilizers are in my opinion a very good idea but require some development to make them economically feasible. The idea is that whatever nutrients are in crops don't disappear but will be in animal/human excrement. It's a 100% efficient process since you can't make matter appear or disappear out of thin air (leaving aside nuclear processes that don't really happen here). So food security won't be compromised, we will have enough of these organic fertilizers for 100% circular economy. We just need to learn to use the correct amount.
If every farm has land for growing crops and a number of animals for meat and milk, most of the crops goes to animals and a very little amount to humans, as animal agriculture is very inefficient. It makes sense to use that animal excrement as fertilizer. Only very little of the nutrients is lost (the amount that humans eat), so some nutrient replacement is necessary using chemical fertilizers.
In today's world, however, there are farms that specialize in growing crops and farms that specialize in meat and milk. It's more economical that way. For example, automated milking machines make sense only if there are a lot of cows, so we will have concentrations of cows producing heavy excrement with some nutrients, and long distance away are the plant-producing farms that have no animals. Unfortunately, transporting that excrement to farms that grow crops may not make sense, since the journey would be long, the product is so heavy and fuels are expensive (and for long journeys battery electric vehicles don't make sense). A solution could be to somehow make two waste streams from that excrement, one that is poor in nutrients but could be used for biogas for example, and another that is rich in nutrients. I think we don't have economically viable commercial solutions for making that nutrient-rich stream yet.
Another problem is that due to limited ability to grow crops on finite land and increasing population and wealth in developing countries, it is imperative that most of the population of this planet goes vegan (not necessarily fully vegan but 70% vegan at least). Without that, we can never produce enough food to feed all starving people. Animal agriculture is just way too inefficient. In this case, the nutrients in human excrement are in the wastewater. So wastewater treatment plants should in the future extract those nutrients and make recycled fertilizer out of them. Otherwise we will lose all of the nutrients.
Nitrogen is something that can be included in fertilizers using chemical processes, no sustainability problems there. Air is mostly nitrogen, and nitrogen can be extracted from it by making liquid air and distilling it. To fix that nitrogen, we need hydrogen, but fortunately that can be made from water and renewable electricity using electrolysis. The main problem in chemical fertilizers is that we have limited phosphorus reserves, so a circular economy would really help there. Fortunately, what phosphorus reserves we have go a long way, so developing solutions to make organic fertilizers make economical sense will have enough time.
I suspect, though, that the final solution will not be to distribute human or animal excrement on crop-producing fields directly but rather make a dense nutrient-rich "semi-organic semi-chemical" fertilizer from recycled nutrients, stopping most phosphorus mining.