Jekyll

Tag: jekyll

  • Moving away from Blogger: comments using Disqus (15 June 2015)

    One of the issues that I needed to face when I decided to move my blog from Blogger to GitHub Pages using Jekyll is how to preserve comments on posts.

    Please welcome Disqus

    Disqus is a discussion (or forum) platform that can be integrated in any content available on the web. In order to integrate something with Disqus the only requirement is that the something can be uniquely identified, and a blog post permalink is an amazing unique identifier :-)

    One of the interesting things that Disqus can do is to integrate itself with Blogger and keep blog post comments synchronized with Disqus comments. Automatically Discqus will utilize the post permalink as the comments unique identifier.

    Once Disqus is in sync with Blogger the blog content can be safely moved to another platform.

    Adding Disqus to Jekyll

    Adding Disqus to Jekyll is as easy as adding the following snippet to the Jekyll post template:

    <div id="disqus_thread"></div>
    <script type="text/javascript">
        /* * * CONFIGURATION VARIABLES * * */
        var disqus_shortname = 'milestonetopicsit';
        
        /* * * DON'T EDIT BELOW THIS LINE * * */
        (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>
    

    But for imported posts it is not enough, comments won’t show up using the above, the commenting form will be displayed but existing comments no. The issue is that the Blogger generated permalink is not the same as the Jekyll one: easy peasy, once again.

    Jekyll supports permalink customization also at the post level, what the Blogger import tool does is to append to each imported post a YAML header such as the following:

    blogger_orig_url: http://milestone.topics.it/2013/04/ravendb-worker-role-on-windows-azure.html
    

    to identify the Blogger original URL, what I simply did is to update each imported post adding a permalink header as well:

    blogger_orig_url: http://milestone.topics.it/2013/04/ravendb-worker-role-on-windows-azure.html
    permalink: /2013/04/ravendb-worker-role-on-windows-azure.html
    

    The permalink header, when used at the post level, overrides the Jekyll default permalink generation behavior for that specific post adding 2 great benefits to the new blog:

    • Old links are still supported, so all the posts linked anywhere will work as expected;
    • Synchronized Disqus comments show up appended to the posts they belong to;

    .m

  • Jekyll: A new home for this blog (12 June 2015)

    I decided to move this blog from Blogger, where it was hosted, to GitHub pages, the main reason that drove this decision is the European cookie law and the absurd way it is applied in Italy, basically forcing me to pay taxes for a thing I am not using but that I cannot disable.

    The interesting thing of GitHub Pages is that they support Jekyll, a ruby powered, blog aware, content generation engine that can generate static sites. And if you think about it a blog is a static thing.

    The blog template I’m actually using is the default one, I don’t like it, I have a plan to create my own template, a long term plan :-)

    .m

  • If you can see this, it worked (12 June 2015)

    One of the things that Jekyll misses is the ability to schedule future posts, but…

    Zapier to the rescue

    Zapier is nice and powerful mesh-up engine that allows you to connect different services, react based on triggers and perform actions.

    Here is my blog posts scheduling work-flow:

    • create a branch to host the new post;
    • write the post in the new branch;
    • push the branch to remote;
    • create an event in my Google Calendar to schedule the publish:
      • use as location the name of the branch;

    I finally created in Zapier a trigger for the Google Calendar event that when the event is fired:

    • automatically creates a Pull Request for the branch defined in the location field;
    • if there are no merge conflicts immediately merges the PR;

    Once the PR is merged into the master branch Jekyll automatically kicks in and compiles the markdown document and publishes it.

    The interesting thing of using a calendar to schedule posts is that you can easily move them to a new schedule and cancel the publish simply deleting the appointment in the calendar without affecting the post sitting in the branch.

    .m