Answer
Gia Long moved the capital from Hanoi to Huế in 1802. This was done in order to consolidate his rule over the country and to make it more difficult for the Chinese to invade. Huế was a more defensible location than Hanoi, as it was located in the mountains and was surrounded by water. It was also a more central location, which made it easier to govern the country.