I noticed that the historic Empire of Ghana was located in present day Mali and Mauritania. Why is the modern country of Ghana located so far away? Or is there even a relation between the two besides a common name?
The modern Republic of Ghana is named in conscious reference to the historical empire.
In the 1940s and 1950s, a nationalist activist from the Gold Coast colony named Dr. J.B. Danquah championed the theory that Akan peoples had originally come from the ancient Ghana empire and had migrated into their current areas of settlement^1. Danquah was not the first to propose that theory, the British anthropologist Eve Meyerovitz had also suggested as much. However, Danquah was quite vocal and quite active in the independence movement, and his theory played a large part in causing Ghana to be adopted as a name.
A secondary and subsidiary factor is also Kwame Nkrumah (the first prime minister and later first president of independent Ghana). His attitude regarding the name can be summarized as generally positive. He favored the reference to a wealthy and powerful African historical polity, as a counterpoint to the contemporar European historical narrative that Africa was without history and without organized states prior to European colonization. To him, using the name Ghana could inspire Ghanaians to rediscover past glories, and to work towards a glorious future.
1- the History of Ghana by Roger Gocking, pp 18