Reputation: 1977
I created a blog and I would like to integrate Disqus into the site so people can post comments. I followed the steps listed on Disqus website, everything was working until the part where I start setting configuration variables. Disqus stopped loading and showing up. I'm not sure what i did wrong here.
Below is my code:
<div id="disqus_thread"></div>
<script>
var disqus_config = function ()
this.page.url = '<%= url_for([@post, {:only_path => false}]) %>'; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = '<%= @post.id %>'; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
this.page.title = '<%= @post.title %>';
};
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = '//york-wang.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
Upvotes: 0
Views: 425
Reputation: 1977
After a few hours of researching, I've finally fixed the issue. Below is the code that i used:
<div id="disqus_thread"></div>
<script>
var disqus_config = function () {
s.src = '//YOURSHORTNAME.disqus.com/embed.js'; // IMPORTANT: Replace EXAMPLE with your forum shortname!
this.page.url = '<%= url_for(@post) %>';
this.page.identifier = '<%= @post.id %>';
this.page.title = '<%= @post.title %>';
};
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = '//YOURSHORTNAME.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
There were 3 problems found: 1. I did not properly configure local dev environment for disqus to connect. 2. I was using an outdated command to map the path to my forum "shortname". 3. The variable for this.page.url was set incorrectly. After fixing the code and uploading everything to the production server, Disqus starts to work again.
Upvotes: 2