At the end of the Middle Ages, most of Ghana was divided into small villages, whose people called themselves the Ashanti. Most Ashanti people grew yams as their staple food, clearing the forest for their fields. Ashanti people got a lot richer when the supply of gold in other West African countries began to run out, and traders started to get their gold from Ghana instead.
In 1701, the Ashanti Empire formed, and controlled most of Ghana and Ivory Coast further west. The Ashanti traded with their neighbors to the north, the Hausa Empire, sending gold and kola nuts (they have caffeine in them) north in exchange for Indian cotton cloth and Ottoman guns.
In the early 1800s, Europeans encouraged the Ashanti to grow cocoa beans, because the American Revolution and the War of 1812 made it hard to get the beans from the Americas. The industry struggled at first, but by 1870, thanks to the work of the Ghanaian Tetteh Quarshie, the Ashanti Empire was growing a lot of cocoa beans to export so Europeans could make chocolate out of it.
In 1895, a British fleet with British soldiers arrived on the coast of Ghana and took it over. The Ashanti kings chose not to resist, because the British army was so much stronger. The Ashante queen Yaa Asantewaa led a fight anyway, but she lost in 1900. Under British rule, Ghana concentrated mainly on growing and exporting cocoa beans. Ghana’s exports haven’t changed that much even since independence in 1957: they still export mostly gold, kola nuts, and cocoa beans.