Trouble including disqus functionality


I’m loving Hugo, but I’m also new to Go templating (and most other things. :slight_smile: ). I’m having trouble getting Disqus working on my blog and I couldn’t seem to find the answer in the other related posts here. I’m hoping it’s just a simple facepalm error on my part. Here’s what I’ve done:

First, I edited my config.toml file to add the line:

disqus_short_name = "MyDisqusShortName"

Then I copied the /theme/detox/layouts/partials/disqus.html file to my own /layouts/partials directory. I’m assuming this will take precedence and override the theme’s copy of it.

The original disqus.html file had the following line:

var disqus_shortname = '{{ . }}';

Which I then changed to:

var disqus_shortname = '{{ .site.Params.disqus_short_name }}'

But nothing shows up on my post. Checking the /theme/detox/layouts/_default/post.html file, it does have the line:

{{ partial "disqus.html" . }}

to include the partial in there, but nothing seems to be happening. I’ve even checked the generated html files, and it doesn’t seem like the disqus.html is getting included in the generated html file at all.

Any ideas where I’m going wrong?

I’ve looked at some of the other theme files, and they’re not all consistent in how they implement it (small things like how the partial file gets included etc). I’m not sure if there is a correct way or not.

Hugo has a built-in template. In your configs add the following line:

title = "Your title"
disqusShortname = "" // Add me and set your shortname

And inside your html template add the following one-liner:

{{ template "_internal/disqus.html" . }}

The comment section will be shown once you added your disqus shortname. For more information read the docs.

Thanks very much. It’s now working. I guess it’s best to use the default and override whatever the theme has provided… at least at first.