What is "nationalism" and how did it lead to imperialism?
Drawing a direct connection between "nationalism," which is endemic to all nation-states, and imperialism is a questionable proposition. If one defines "nationalism" as strong feelings of loyalty to one's country and an innate belief in its goodness, than nationalism in and of itself cannot necessarily be equated with or even a contributor to imperialist policies. Taken to its extreme, to include in its definition an intense feeling of superiority over other nations, then it could spawn policies that manifest themselves in imperialist ambitions. Such was certainly the case with Nazi Germany, which clung to an extreme nationalist culture imbued with a sense of racial or ethnic superiority over other nations and ethnicities, and which resulted in invasions of many countries, especially in the Slavic realm, intended to subjugate the native peoples for purposes of enslavement.
Mainstream nationalism, however, is simply characterized by feelings of pride in one's country and a strong desire to see it prevail in international competitions and negotiations. The populations of virtually every country in the world can be characterized as nationalistic in terms of pride in country. The Japanese, for instance, remain almost as nationalistic today as during the period of Imperial Japan, but post-World War II political transformations driven by U.S. occupation policies have eliminated from mainstream Japanese thinking the notion of imperialistic endeavors. British imperialism was driven by a combination of nationalistic sentiments and economic ambitions. Since the decline of the British Empire, however, it has eschewed imperialistic ambitions, but the underlying sense of British greatness remains.
Imperialism, driven mostly by economic and occasionally geopolitical considerations, does not derive automatically from nationalism. One can logically argue that all historical cases of imperialism have involved countries imbued with strong senses of nationalism, but that would not account for the huge discrepency between the number of nationalistic populations and imperialistic ambitions on the part of those same people. As political cultures change, popular perceptions of a country's place in the world change with them. Pride in country, though, remains.
People celebrate their differences. They value their cultures, languages, histories, and sense of uniqueness. They may even believe in their superiorty relative to other nationalities. That does not, however, translate to imperialist policies.
Nationalism is a strong sense of pride and attachment that people of a country and or culture tend to exude. Some may call them patriotic. Some example of nationalism is when people are proud to say they are from France, Brazil or Canada.
Imperialism is when a country decides to push their agenda and ideals on another country usually through military force. A great example of imperialism is when Japan invaded Korea and implemented a Japanese regime over Koreans. another example would be Theodore Roosevelt taking Puerto Rico and Cuba as apart of U.S. territory.
Nationalism leads to imperialism when certain people feel that it is in their countries best interest to gain as much as they need in or to protect their country. For Roosevelt it was ports and for Japan it was resources.
Nationalism is an ideology; it is a belief in one's country to be independent from the rule of other aggressively ruling country (imperialist). You can say that nationalism is related to patriotism because that individual is devoted to his nation and is willing to do all that is necessary to achieve freedom.
Nationalism leads to Imperialism because the imperialist country strictly rules the other country and has no regard for their well-being they only care about how much resources they can get out of the people, which leads the individuals of the oppressed nation towards Nationalism. You can take the example of India, Vietnam etc.