xiaoheiAh/hugo-theme-pure

Disqus embed not working

SathyaBhat opened this issue · 5 comments

Hello,

Thank you for your theme. I'm trying to setup disqus, but it seems to not inject disqus' js code.

site: https://sathyasays.com/
config: https://github.com/SathyaBhat/sathyasays.com/blob/master/config.yml#L128-L129

Looking at the source, I can see the comment section is added

<section id="comments">
    <div id="disqus_thread">
        <noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
    </div>
</section>

which means

https://github.com/xiaoheiAh/hugo-theme-pure/blob/master/layouts/partials/post/comment.html#L4-L7

is working but I don't know why

https://github.com/xiaoheiAh/hugo-theme-pure/blob/master/layouts/partials/_script/comment.html#L25-L36

is not getting evaluated.

Any help is appreciated

Is clearly working for me with latest hugo and theme, see https://sbarnea.com -- look at JS console for errors.

@ssbarnea thank you - no JS console errors for me and I just updated netlify to use 0.62, no dice.

In this theme, disqus allow to be loaded in the local environment.You can take a debug.
Checkout if disqus.js be loaded.I tested it and worked for me.

Unfortunately disqus.js doesnt seem to be loaded, even though the partial is picked up

hugo --debug serve
...

DEBUG 2019/12/31 19:16:21 Add template file: name "partials/_script/comment.html", baseTemplatePath "", path "partials/_script/comment.html"

DEBUG 2019/12/31 19:16:21 Add template file: name "partials/post/category.html", baseTemplatePath "", path "partials/post/category.html"
..
INFO 2019/12/31 19:16:21 Using config file:
Building sites … INFO 2019/12/31 19:16:21 syncing static files to /

Ok, I found the problem. Most of my posts have

type: post

where this is present, the partials script for embedding is not entering the if condition and so disqus embed js is not added

https://github.com/xiaoheiAh/hugo-theme-pure/blob/master/layouts/partials/script.html#L63

changing mainSections in config.yml from "posts" to "post" means the condition is matched and this works again