I already explained a few things about how I migrated from WordPress to Jekyll. A few basic things that come for free in WordPress are not available out of the box in Jekyll. Comments section is one example and you already know that I am now using Commento as the comments engine. Another thing that came for free with WordPress was pagination which was missing from Jekyll in the basic form. A few other things that one could add to WordPress using plugins was setting up analytics, rss feeds, site-map, ads, subscription service etc. Here is how I went about adding some of those features in Jekyll.


Pagination

For pagination support in Jekyll I used the jekyll-paginate-v2 plugin. Basically add gem 'jekyll-paginate-v2' to jekyll_plugins group in the Gemfile. Then include jekyll-paginate-v2 under the plugins sections of _config.yml. Finally I configured _config.yml with the following to get everything the way I wanted.

# Show 10 articles per page
pagination:
  enabled: true
  per_page: 10
  permalink: '/page/:num/'
  sort_reverse: true
  # Show unlimited page numbers
  trail:
    before: 1000
    after: 1000

# Generate pagination for tags and categories
autopages:
  enabled: true
  categories:
    permalink: '/category/:cat/'
    title: 'Posts in category ":cat"'
    layouts: 
      - 'category.html'
    slugify:
      mode: 'default'
      case: false
  tags:
    permalink: '/tag/:tag/'
    title: 'Posts tagged with ":tag"'
    layouts: 
      - 'tag.html'
    slugify:
      mode: 'default'
      case: false


Analytics

Adding Google Analytics was easy because I was using the minima theme which comes with all the code required to insert analytics. Basically you assign the Analytics ID to google_analytics in _config.yml.


Sitemap and Google News feed

Adding a sitemap was also easy using the jekyll-sitemap. Just like with pagination, add the plugin to the Gemfile and _config.yml. In addition you might want to add a robots.txt file. Google News needs another plugin jekyll-feed. Like before, update the Gemfile and _config.yml files. In addition to generate specific categories in the news feed, I added the following to _config.yml.

feed:
  excerpt_only: true
  categories: 
    - Early Retirement
    - Financial Planning
    - Post Retirement
    - Unschooling
    - Sustainable Living
    - Philosophy
    - Financial Planning


Archives

Next comes adding archives to the page. Again, what was free in WordPress needs a little bit of work with Jekyll. Add the plugin jekyll-archives like before. Then to show the archives in the sidebar, I added the following code –


<h3 class="heading">Archives</h3>
<ul>
  {% for post in site.posts %}
  {% capture this_year %}{{ post.date | date: "%Y" }}{% endcapture %}
  {% capture pre_year %}{{ post.previous.date | date: "%Y" }}{% endcapture %}

  {% if forloop.first %}
  {% assign last_month = "" %}
  <li><strong>{{this_year}}</strong></li>
  <ul>
    {% endif %}
    {% capture this_month %}{{ post.date | date: "%m" }}{% endcapture %}
    {% if last_month != this_month %}
    <li>
      {% capture this_month_name %}{{ post.date | date: "%B" }}{% endcapture %}
      <a href="/archives/{{ this_year }}/{{ this_month }}">{{ this_month_name }}</a>
    </li>
    {% assign last_month = this_month %}
    {% endif %}
    {% if forloop.last %}
  </ul>
  {% elsif this_year != pre_year %}
</ul>
<li><strong>{{pre_year}}</strong></li>
<ul>
  {% assign last_month = "" %}
  {% endif %}
  {% endfor %}
</ul>


To show articles in categories, add this code


{% assign sort_categories = site.categories | sort %}

<h3 class="heading">Categories</h3>
<ul>
  {% for category in sort_categories } %}
  {% assign category_name = category | first %}
  {% capture _category_url %}/category/{{ category_name | slugify | url_encode }}/{% endcapture %}
  <li><a href="{{ _category_url }}">{{ category_name }}</a></li>
  {% endfor %}
</ul>


Google Forms

Since Jekyll lacks any way to create forms unlike in WordPress, I started using Google Forms for all kinds of user input. So contact me simply loads up a Google Form that I created and the user inputs are sent to my email. Same is the case with the virtual meet-up form.


Subscription

I use MailChimp for my subscription service. So I created a form in MailChimp and copy pasted the code where ever I needed a subscription form.


Other details

There are a lot more things that I had to do to finally port over the blog to Jekyll, but will not go into much details because they require a lot more work. But more importantly there are better articles out there on the web. Some of the topics that I did not cover include adding

  • related articles to the end of each post
  • search functionality
  • ads


Conclusion

That concludes the series on migrating from WordPress to Jekyll. Hope it helps someone who is getting started on Jekyll.