Hugo config.toml failed with disqus and privacy.disqus

Hi,

I’m new to Hugo, and I’m planning to add disqus comment system to my hugo site.

My config.toml is like this:

baseURL = "https://marguerite.github.io"
languageCode = "zh-cn"
title = "Marguerite Su: Golang/Ruby Programmer, openSUSE Member"
theme = "blank"
disqusShortname = "innamoramento"
[privacy]
    [privacy.disqus]
        disable = false

When I ran “hugo -D”, it kept complaining:

Error: Error building site: failed to render pages: render of "page" failed: execute of template failed: template: _internal/disqus.html:1:16: executing "_internal/disqus.html" at <.Site.Config.Privacy.Disqus>: can't evaluate field Site in type string

I guess hugo just can’t find disqus privacy settings. I searched around the hugo codebase and copyed back:

baseURL = "https://marguerite.github.io"
languageCode = "zh-cn"
title = "Marguerite Su: Golang/Ruby Programmer, openSUSE Member"
theme = "blank"
[privacy]
[privacy.disqus]
disable = false
[services]
[services.disqus]
shortname = "innamoramento"

But still get no luck.

Currently I can get disqus work by add a paritial which works around the privacy system :frowning:

But I’m lazy, I just want to use the default…

Thanks for any help

Marguerite

Remove that [services] stuff. That has no function.

Remove that [privacy.disqus] section, false is the default is the default setting and these lines have no function.

The error is: at <.Site.Config.Privacy.Disqus>: can't evaluate field Site in type string - this points to a problem further up the line. Hugo can’t evaluate the Site parameter, not the privacy.disqus-part. Check your config.toml if there are toplevel settings between subsections, if there are multiple privacy sections and so on.

If removing those points do not change the issue then please post a link to your repo, there are more points where error might occur, but I suspect issues with the structure of your configuration file.

how do you implement this line in your template?

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

because if you put it inside a with block like this, it cannot access the .Site variable.

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

or anything like remapped partial context.

{{ partial "partialName.html" (dict "key" "value") }}
1 Like

That would probably be worth a bug report on Github if that is the case. Internal templates should access variables from the root ($) instead of assuming how they are called.

@davidsneighbour

The first code block in the initial post contains all my config.toml content. :sweat_smile: you know I am lazy, the “blank” theme is also a skeleton :stuck_out_tongue_closed_eyes:

The same error occurs if I removed all the privacy stuff.

@pamubay

Thanks for clarifying. And I think you just caught the bug (because as you can see, I didn’t have much stuff that can cause errors in my repository)

Theme “blank” codes disqus template just like you said:
https://github.com/Vimux/blank/blob/master/layouts/_default/single.html

{{ with .Site.DisqusShortname }}
<div>
  {{ template "_internal/disqus.html" . }}
</div>
{{ end }}

where the Site can not be accessed.