Google Plus comments link for Octopress

Need Octopress blog posts to auto link to your Google Plus post for comments?

I did, heres how to make Octopress add a comments link to the bottom of each blog post


  1. I wanted blog visitors to be able to comment and discuss the post without all the comments appearing at the bottom of the post
  2. I didn’t want to have to manually add a link to the Google+ post
  3. I didn’t want to use a comment system like Disqus
  4. Google Plus is best place these type of comments/post discussions, it sorts our all the spam and you only get good comments as real names are used

How to

Enable Google Plus for Octopress, then add this into source/_includes/custom/after_footer.html


{% comment %}
  Add content to be output at the bottom of each page. (You might use this for analytics scripts, for example)
{% endcomment %}
{% if page.comments == true %}
<script type="text/javascript">
jQuery(document).ready(function() {
    //$post_title = $('header .entry-title').text();
    //$post_domain = document.domain;
    if( jQuery('article').hasClass('hentry') )
        $post_link = encodeURI(jQuery(location).attr('href'));
        $gp_url = jQuery('.googleplus h1 a').attr('href');
        $google_plus_id = $gp_url.split('/')[3].split('?')[0] ;
        $google_query_url = "" +
                            $post_link +
                            "&maxResults=20&orderBy=best&fields=id%2Citems(actor(displayName%2Cid%2Curl)" +
            function(data) {
                jQuery.each(data.items, function(i,item){
                    if( == $google_plus_id)
                        jQuery('.entry-content').append( "<h3>Comments?</h3><p>Join the discussion at the <a href='" + item.object.url +"'>Google+ post</a></p>");
                        return false;
{% endif %}

Note: you need to replace the {YOUR_GOOGLE_API_KEY} section with your google api key

Next, modify source/_includes/custom/head.html to include <script> tags for jQuery

<script src="" type="text/javascript"></script>
<script type="text/javascript">jQuery.noConflict();</script>


Now after you do a new blog post using Octopress, just +1 the post. The script will look for the +1 done by the blog owner and if it finds one it’ll link to it

See it in action

Open this blog post and just look at the bottom of the page, you’ll see a Comments? refer the Google+ post link


  • You need a Google API key to use this
  • Comments have to be enabled for the blog post
  • The link only appears when the blog post is open - not in the index/front-page view
  • This assumes your using the default Octopress theme - if you using something different you’ll have to customise the script

Justin Kelly

Justin Kelly

Data Engineeer, Business Analytics, Web Developer, Library Technology specialising in PHP and Tableau

Based in Melbourne, Australia

Feel free to contact me or _justin_kelly