hugo-theme-bleak
hugo-theme-bleak copied to clipboard
Disqus doesn't load
When entering my disqus ID into the config and reloading the application disqus comments do not appear on any of the posts.
the code required for disqus to load after an ajax request is different from the code required for a normal page load it seems . It seems disqus has to do some reset of some sort. You can see the warnings by looking at your browser console. I had to modify a few things on my end before it worked. This is what i ended up with but my code also contains some extra stuff also for identifying the specific page through the hugo slug also .
<input type="hidden" id="disq_variables" name="disq_variables" data-ident="{{ .Params.slug }}" data-url="{{ .Permalink }}"/>
<aside class="post-comments">
{{ if ne .Params.comments false}}
{{ with .Site.Params.disqusShortname }}
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disq_var = document.getElementById('disq_variables');
var disqus_shortname = 'https-nayibor-github-io';
var disqus_identifier = disq_var.getAttribute('data-ident');
var disqus_url = disq_var.getAttribute('data-url');
var disqus_config = function () {
this.language = "en";
};
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
/* * * Disqus Reset Function * * */
var reset = function (newIdentifier, newUrl, newTitle, newLanguage) {
DISQUS.reset({
reload: true,
config: function () {
this.page.identifier = newIdentifier;
this.page.url = newUrl;
this.page.title = newTitle;
this.language = newLanguage;
}
});
};
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
{{ end }}
{{ end }}
</aside>