Nietzsche referred very often and very clearly to anti-Semites as the scum of the Earth, and to him, nationalists of any sort weren't much better. Certainly not German nationalists. His books positively overflow with disparaging remarks about Germany. There are only a small fraction as many positive remarks about Germany.
So how did so many people come to associate Nietzsche with the Nazis, including many Nazis themselves? The fact that Nazis tended not to be at all well-read is only part of the story.
The thing about Nietzsche and the Nazis is that his sister, Elisabeth Förster-Nietzsche, WAS both an extreme antisemite, and the executor of Nietzsche's affairs from the time he went insane in 1889 until she died in 1935. Elizabeth's husband was the leader of a political party which actually had "antisemitic" in its name, in case anyone wasn't clear about where the party was coming from.
Even before 1889 Elizabeth did everything she could to associate her famous brother with her political causes. Nietzsche protested this, even threatened to publicly disown her over it. After 1889 he wasn't able to protest any more. She altered new editions of his books. The book Der Wille zur Macht (The Will to Power) isn't actually by Nietzsche. Elizabeth put it together from his notebooks.
Anyway, if you look at Elizabeth Foerster-Nietzsche and her influence, and not just at the original editions of Nietzsche's works or recent ones which have been restored to the way Nietzsche wrote them, then it becomes easier to understand how so many people came to think that Nietzsche was one of the forerunners of the Nazis. If you only look at what Nietzsche actually wrote, it's as obvious as can be that he was, in Allan Bloom's words, "the very opposite of an anti-Semite." (The Closing of the American Mind, New York: Simon and Schuster, 1987, p 149.) That's one of the comparatively few things about which Bloom and I agree. No one who is at all familiar with Nietzsche's authentic work, the work which is really his, unaltered by his vile crazy racist sister, can help but agree about that. His opposition to anti-Semitism is about as clear as anything in his works, which of course are full of difficult and ambiguous passages. There's nothing ambiguous about his opposition to anti-Semitism. Nothing. Period. Next!