There are many reasons why nationalism went out of fashion in the latter part of the 20th century. One of the reasons, not usually considered, is that nationalism is in fact rather artificial. Or perhaps it’s more accurate to say that nationalism in practice has often been rather artificial.
The boundaries of most nation states as they exist today reflect historical accidents, military conquest, the whims of statesmen and the vagaries of long-ago dynastic politics. Most nation states are not organic ethnostates. Some European nations are true ethnostates. Poland for example, although that’s largely the result of some brutal ethnic cleansing after the Second World War. More typical are countries like Switzerland, Belgium and the United Kingdom - different and not always compatible ethnicities forced together for reasons that may have made sense centuries ago. The Swiss had their reasons and due to their federal system their country has succeeded. The United Kingdom has been less happy. The Welsh, the Cornish, the Irish and the Scots were all incorporated, very unwillingly, into an English-dominated state. As for Belgium, no-one really remembers why anybody thought Belgium was a good idea.
Even nations like Germany and Italy were (before they chose to commit suicide) not quite the straightforward ethnostates they seemed to be. To make those countries work strong regional identities had to be crushed. Prior to unification Germans had a sense of German-ness but Bavarians also had a sense of Bavarian-ness and Swabians had a sense of Swabian-ness. Northern and southern Italians retain some degree of regional identity, hence the push for independence for northern Italy.
The strongest ties of identity that we have tend to be local. Regional ties can be strong also. National ties can be more problematic. If a nation isn’t an ethnostate then there’s nothing really substantial to unite the population. Attempts to construct nationalism on the basis of “shared values” or “civic nationalism” have been dismal failures. There aren’t any shared values any more, and there never were.
It’s a particular problem for artificial nations like Australia, Canada and the United States. Australia really has no sense of national identity at all. One was perhaps starting to emerge in the first half of the 20th century but the tidal wave of American culture that engulfed us after the Second World War put an end to that. We don’t have regional identities either. The US does seem at one time to have had strong regional identities but they have been fairly relentlessly crushed by the monolithic trash culture of Hollywood, social media and pop music.
Nationalism is certainly preferable to globalism, but perhaps it’s not a complete answer. Whether regionalism or localism would be any more successful in resisting globalism is of course another matter.