Add Comments to Your Hugo Site
Comments, Reactions, and Ratings in One Hugo Partial
Hugo builds your site in milliseconds. Adding comments takes a few minutes. Create a partial, call it from your single page layout, and every post gets a comment section with moderation built in.
Steps to Add Comments to Hugo
Sign up at the Hyvor Talk Console, add your website with your site's domain, and copy the website ID from Settings → Website.
Add the website ID to your site configuration (
hugo.toml):[params] hyvorTalkWebsiteId = 'YOUR_WEBSITE_ID'Create
layouts/partials/comments.html. It only renders when the website ID is set, and skips pages withcomments: falsein their front matter.{{ with site.Params.hyvorTalkWebsiteId }} {{ if ne $.Params.comments false }} <script async src="https://talk.hyvor.com/embed/embed.js" type="module"></script> <hyvor-talk-comments website-id="{{ . }}" page-id="{{ with $.File }}{{ .Path }}{{ end }}" ></hyvor-talk-comments> {{ end }} {{ end }}Call the partial from your single page layout, after
.Content. Using a theme? Copy its single page template (for examplelayouts/_default/single.html) into your project'slayoutsfolder with the same path, and edit the copy. Hugo uses yours over the theme's.{{ define "main" }} <article> <h1>{{ .Title }}</h1> {{ .Content }} </article> {{ partial "comments.html" . }} {{ end }}Run
hugo serverand open a post. To see the comments locally, addlocalhostto Settings → Website → Allowed Domains in the Console.
Match your theme's dark mode
Many Hugo themes follow the visitor's system theme. Set colors="os" and the
comments do the same. You can also use light or dark. See styles.
<hyvor-talk-comments
website-id="{{ . }}"
page-id="{{ with $.File }}{{ .Path }}{{ end }}"
colors="os"
></hyvor-talk-comments>That's it. Deploy your site and the comments are live on every post. Head to the Console to set up moderation and change the texts.
Frequently asked questions
Yes. Hugo outputs static files, and Hyvor Talk loads the comments in the browser from its own servers. Readers can post right away, and you don't need to rebuild the site for new comments to appear.
No. A partial with a few lines of HTML works like a comments plugin and fits any theme. You don't add any modules or dependencies to your site.
Find where your theme renders Disqus in its single page layout and put {{ partial "comments.html" . }} there instead. You can also import your Disqus comments first, so nothing gets lost.
The file path, like posts/my-first-post.md, stays the same when you change your permalink settings. That keeps each thread attached to its post. Without a page ID, Hyvor Talk uses the URL. See page-id.
Yes. Add comments = false (TOML) or comments: false (YAML) to its front matter. The partial skips the embed for that page.
Reactions and star ratings, reply notifications by email, spam filtering, and moderation tools. The comment section is also available in 30+ languages, which suits multilingual Hugo sites.
14 days, and you can start without a credit card. Plans are on the pricing page.