Get the disqus system working on the comments pags

Posted on Thu 21 December 2017 in Python

Looking into the Disqus_static led me to all sorts of import and set up issues, so I started looking at incuding the universal JS for this.

Digging into the template files, I found the author had already included this on the articles.html template

themes/medius/templates/articles.html

We can see here that its already got pretty much everything we need

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
{% if DISQUS_SITENAME %}
    <div class="entry-content">
        <div id="disqus_thread"></div>
        <script type="text/javascript">
            var disqus_shortname = '{{ DISQUS_SITENAME }}';
            (function() {
                var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
                dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
                (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
            })();
        </script>
        <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
    </div>
    {% endif %}

So what do we do to get this to activate?

The clue is in the if DISQUS_SITENAME, remember our config file, lets add it in there (pelicanconf.py)

1
DISQUS_SITENAME = '11eight-co-uk'

Note to self: I did have the sitename as 11eight.co.uk and this chucked up JS https errors when loading pages. Looking into it, it seems we need the SHORTNAME from Disqus in here, which replaces the . with - and so allows Disqus wildcard SSL cert to work on the subdomain Wildcard certs only allow the domain level they are on (so 11eight.co.uk.disqus.com is not valid)

Next up Hosting. (Raspberry PI and Cloudflare-warp I think !)