Considering the fact that Vietnam was able to, more or less, defeat both France and the United States in the twentieth century and that the region has a strong tradition of defending against foreign invasions, how was the French originally able to conquer Vietnam during the age of imperialism? Why was France able to beat the Vietnamese in the nineteenth century, but not the twentieth?
It's because after the French helped the Southern Vietnamese establish the Nguyen dynasty under Emperor Gia Long, the next successors however decided to close off Vietnam to trading with foreign nations including the French who used to supply the Vietnamese with arms and weapons. After about 30 years of isolation, their naval yards and weapons were simply outdated compared to the French. Early 19th century French warfare tech was no match against mid 19th century French warfare tech. Also it didn't help that the Catholics in the country were being persecuted were revolting against the ruling monarch.