<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Desired Persona</title>
    <description>The latest articles on DEV Community by Desired Persona (@desiredpersona).</description>
    <link>https://dev.to/desiredpersona</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F51702%2Fb4bbe034-ae83-4c5f-9e45-8c92afe1690c.jpeg</url>
      <title>DEV Community: Desired Persona</title>
      <link>https://dev.to/desiredpersona</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/desiredpersona"/>
    <language>en</language>
    <item>
      <title>Disqus comments setup for Jekyll</title>
      <dc:creator>Desired Persona</dc:creator>
      <pubDate>Wed, 11 May 2016 22:30:00 +0000</pubDate>
      <link>https://dev.to/desiredpersona/disqus-comments-setup-for-jekyll-227o</link>
      <guid>https://dev.to/desiredpersona/disqus-comments-setup-for-jekyll-227o</guid>
      <description>&lt;p&gt;I recently added Disqus to my Jekyll powered website. This guide will keep the code clutter free and as reusable as possible.&lt;/p&gt;

&lt;p&gt;Open &lt;code&gt;config.yml&lt;/code&gt; and add the following code. Remember to change &lt;code&gt;my_disqus_shortname&lt;/code&gt; to your own Disqus shortname.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Disqus Comments
disqus:
    # Leave shortname blank to disable comments site-wide.
    # Disable comments for any post by adding `comments: false` to that post's YAML Front Matter.
    shortname: my_disqus_shortname
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a file called &lt;code&gt;disqus_comments.html&lt;/code&gt; in Jekyll’s &lt;code&gt;_includes&lt;/code&gt; folder and add the following code and save the file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{% if page.comments != false and jekyll.environment == "production" %}

  &amp;lt;div id="disqus_thread"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;script&amp;gt;
    var disqus_config = function () {
      this.page.url = '{{ page.url | absolute_url }}';
      this.page.identifier = '{{ page.url | absolute_url }}';
    };
    (function() {
      var d = document, s = d.createElement('script');
      s.src = 'https://{{ site.disqus.shortname }}.disqus.com/embed.js';
      s.setAttribute('data-timestamp', +new Date());
      (d.head || d.body).appendChild(s);
    })();
  &amp;lt;/script&amp;gt;
  &amp;lt;noscript&amp;gt;Please enable JavaScript to view the &amp;lt;a href="https://disqus.com/?ref_noscript" rel="nofollow"&amp;gt;comments powered by Disqus.&amp;lt;/a&amp;gt;&amp;lt;/noscript&amp;gt;
{% endif %}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above codeblock includes your &lt;a href="https://disqus.com/admin/universalcode/"&gt;Disqus Universal Embed Code&lt;/a&gt;. You may have noticed that i wrapped the code between &lt;code&gt;{% if page.comments != false and jekyll.environment == "production" %}&lt;/code&gt; and &lt;code&gt;{% endif %}&lt;/code&gt; liquid if statement. This included if statement will allow you to disable Disqus comments on any blog post. You simply add &lt;code&gt;comments: false&lt;/code&gt; in that posts YAML front-matter. As an added bonus it will also prevent Disqus loading when Jekyll’s environment is set to development.&lt;/p&gt;

&lt;p&gt;Finally, open your &lt;code&gt;post.html&lt;/code&gt; file and add the following liquid include tag just after the end &lt;code&gt;&amp;lt;/article&amp;gt;&lt;/code&gt; tag. This will load Disqus comments right underneath your blog posts when Jekyll’s environment is set to production.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{% if site.disqus.shortname %}
  {% include disqus_comments.html %}
{% endif %}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To build your Jekyll site in production environment use the following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;JEKYLL_ENV=production bundle exec jekyll build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Done!&lt;/p&gt;

&lt;p&gt;Disqus comments should now be working correctly.&lt;/p&gt;

&lt;p&gt;Let me know in the comments if you found this tutorial helpful?&lt;/p&gt;

</description>
      <category>jekyll</category>
      <category>disqus</category>
      <category>comments</category>
    </item>
  </channel>
</rss>
