How to add comments to Squarespace Courses using Disqus

Replace YOURSHORTNAME in the code below with your disqus shortname and add the page header code injection for your course.

<script>
document.addEventListener("DOMContentLoaded", function() {
    // Define the Disqus configuration
    var disqus_config = function () {
        this.page.url = window.location.href;  
        this.page.identifier = window.location.pathname;
    };

    // Function to add Disqus to the page
    function addDisqus() {
        // Create the Disqus div
        var disqusDiv = document.createElement('div');
        disqusDiv.id = 'disqus_thread';

        // Find the last article element on the page
        var articles = document.querySelectorAll('article');
        var lastArticle = articles[articles.length - 1];

        // Insert the Disqus div after the last article
        if (lastArticle) {
            lastArticle.parentNode.insertBefore(disqusDiv, lastArticle.nextSibling);
        }

        // Disqus embed script
        var d = document, s = d.createElement('script');
        s.src = 'https://YOURSHORTNAME.disqus.com/embed.js';
        s.setAttribute('data-timestamp', +new Date());
        (d.head || d.body).appendChild(s);
    }

    // Add Disqus to the page
    addDisqus();
});
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>

Where to find your disqus shortname

Settings > General

Omari Harebin

Founder of SQSPThemes.com, one of the worlds most trusted Squarespace resources. Since 2015 we’ve helped over 20,000 Squarespace users grow their businesses with custom templates, plugins and integrations.

https://www.sqspthemes.com
Previous
Previous

How to get your business registered and online in 20 minutes

Next
Next

How to customize your Squarespace course labels