Integrating Disqus with Hugo
- Pitfall
Hugo has built-in support for Disqus. In theory, you only need to set the disqusShortname
attribute at the top level of your site’s config.toml
file. However, there are some pitfalls when actually using it. Here are the specific steps.
- Register your own account on the Disqus website.
- After logging in to the Disqus website, go to Settings in the upper right corner, then select Moderation on the left side. Here, create a new site, and the site name (
{site_name}.disqus.com
) should be used as the value fordisqusShortname
. - Once the site is created, choose the Free Plan on the Billing page.
- Set the
disqusShortname
in theconfig.toml
file of Hugo.
Other minor issues:
- No comments displayed locally: In the theme’s
disqus.html
file (located at{site_folder}\themes\{theme_name}\layouts\partials\disqus.html
), the comment box will not load when the condition (indow.location.hostname == "localhost"
) is met. If you need to debug, you can add a comment to this condition, and it will display normally locally.