NATO is a military alliance, but diplomacy is essential to its unity and efficacy. So President Trump's undiplomatic public hectoring of allies regarding defense expenditures and his lack of clarity on collective defense erodes NATO unity at a time when terrorism and Russian aggression make the transatlantic alliance more necessary than ever.

Trump's concern over military expenditures is legitimate. Of the 28 countries in the alliance (soon to be 29 when Montenegro officially joins), only five (Poland, Estonia, Greece, the United Kingdom and the U.S.) invest the targeted 2 percent of GDP on defense. Most have pledged to hit the goal by 2024, and many have already increased their investment.

But just as in the U.S., hiking military spending is a political decision that depends on elected legislatures and supportive citizens who are far more likely to respond to positive calls for collective investment than scolding from a president who is particularly unpopular in Europe.

Conversely, NATO's image has improved on both sides of the Atlantic, according to a new Pew Research Center poll released this week. This surge in support should create the political conditions in Europe for all members to meet the 2 percent target, but Trump's comments risk being counterproductive.

His apparent omission of NATO's Article 5 wasn't as significant a misstep, but it comes in a context of candidate Trump labeling NATO "obsolete." The president has backtracked from such an unwise characterization, and he should have been clearer on committing to collective defense. It's worth noting that Article 5 on that subject has been invoked only once — by the U.S. after 9/11.

The president should be pleased that NATO has now officially joined the multinational fight against ISIS. But it should be noted that Europeans have already been involved in this fight, both at home and abroad.

Trump's comments were delivered at the new NATO headquarters in Brussels, in front of a new sculpture made of mangled steel from the 9/11 attacks. It should have been a time of consensus, not contention. Instead, the image replayed endlessly is of Trump pushing past Montenegro's prime minister to be in the front row for the official NATO photo.

Optics matter. Substance even more so. On both accounts, President Trump has room to improve.