There’s a book about this! Salt: A World History by Mark Kurlansky.
The answer varies by location, but salt was most commonly obtained either by mining or (more commonly) by evaporating water & collecting the salt left behind. It was historically a very common trade good, so locations which lacked robust salt production simply traded for it. There isn’t really a period of human history where zero cultural exchange was taking place; we were always trading with each other, just not on the large scale modern advances in transportation allow for today.
Latest Answers