All right fine. Some visitor may want to leave a comment about one or another of my posts. I can do that with Hugo.
I used the documented steps for adding Disqus comments to Hugo. Though Hugo provides a usable internal template for Disqus, using it as-is will result in a record-keeping headache if you test your site locally.
- You look at the page locally
- The Disqus code is loaded
- Disqus creates a new comment thread for your local page
- Before you know it you have dozens of
localhost:1313
comment threads obscuring the live threads.
To avoid that, use the following partials/disqus.html
fragment described
in the Hugo documentation. It will skip loading comments when viewing your
content from localhost.
That template needs .Site.DisqusShortname
, which you set in your site config.
Now you can use the partial in the appropriate template. I put the call for mine in _default/single.ace
.
There. Now if you really want to say anything, are viewing the live site, and have JavaScript enabled, you can in the section below.
I will probably adjust the template over time, since I don’t want to burden non-commenting visitors with the extra load from calling out to Disqus. I like the approach David Wheeler took with his site: do nothing until visitor directly uses the “Load Comments” button.