-my $comment="[[!comment format=mdwn\n";
-$comment.=" username=\"$username\"\n";
-$comment.=" subject=\"\"\"comment $comment_num\"\"\"\n";
-$comment.=" " . IkiWiki::Plugin::comments::commentdate() . "\n";
-$comment.=" content=\"\"\"\n\n\"\"\"]]\n";
+ # This will yield a hash of the comment before it's edited,
+ # but that's ok; the date provides sufficient entropy to avoid collisions,
+ # and the hash of a comment does not need to match its actual content.
+ # Doing it this way avoids needing to move the file to a final
+ # location after it's edited.
+ my $location=IkiWiki::Plugin::comments::unique_comment_location($page, $comment, $dir)."._comment";