Blog Posts Not Showing on Github Pages

Post from the Rails category

Time No matter how long you've been developing, there's one thing we all struggle with: Timezones.

It is a common thing: dealing with timezones is a nightmare in every project. Most remarkably, some of the biggest technological fuckups in history involve timezones and formats. Leap years, American vs. European date format, etc.

But if there's something more annoying than having to deal with timezones is not really knowing that timezones are to blame when things break down. That is: something is not working, but you can't really expect timezones to be involved.

That's my recent case: yesterday I wanted to publish a blog post in this very site. When you create a blog post in Jekyll, you need to include the frontmatter, setting some metadata that will create the post according to the variables therein. For instance, this post's frontmatter is:

layout: post
title: Blog Posts Not Showing on Github Pages
date: 2016-03-20T20:20:46.000Z
categories: ruby rails
icon: rails

Since I assumed I was going to publish the post later in time, I set a future date. Unbeknownst to me, Jekyll recognises future posts and will not display them in Github Pages (where this site is hosted) until that time is reached.

Therefore, I could see it in my local environment, but not live.

When I realised that, I quickly changed the time to a past date, to no avail: somehow, the metadata stays in the file, and you need to delete it and create it anew, thus forcing a new build.

I faced this very issue again today with the MarsBased website, just that this time, the website is built using Middleman. Same dog, different collar. Everything I said about Jekyll previously applies to Middleman now.

I wanted to publish a post tomorrow, so I saved the file with tomorrow's date. When I realised I could publish today instead, I reverted, but it was too late. I then proceeded to check the time, and corrected the time variable in the frontmatter to match the current value. When I deployed to Github Pages, however, it would not show, even though the time was right.

Looks like Middleman comes with UTC as a default timezone. Therefore, even if I had the right time written, for Middleman it was London time, hence not displaying the post as it understood it was programmed for the next hour.

Setting the = "Berlin" in Middleman's config.rb file solved the issue.

On Jekyll, to do the same, you do it in the _config.yml file with the following key/value combination:
timezone: 'Europe/Andorra'.

Therefore, lessons learnt:

  1. Never create posts with future times, not even for testing. Create them with past dates instead.
  2. Set the timezone first thing when you set up your Jekyll/Middleman projects.

By the way: there are a million other reasons why your post might not show up on Github Pages: incorrect characters in the title (double colon, most likely), your post does not follow the naming conventions, or many others, but I won't cover them in this post.

Now Playing: Omnium Gathering - The Great Liberation.