Delan Azabani

Forcing a single timezone in Jekyll

 243 words 1 min  home jekyll

Alternatively, How I Learned to Stop Worrying and Love UTC. It was a little more subtle than I had expected to ensure that Jekyll uses an arbitrary timezone for dates in posts and their generated URLs, but is that even a Good Thing™ to do?

My posts were timestamped in their YAML front matter like so:

date: 2014-01-03 07:00:00 +0800

Then I tried adding this to _config.yml:

timezone: Australia/Perth

It appeared that this had no effect at all. URLs were still being generated based on the date in UTC, and displayed post dates were still:

2014-01-02 23:00 UTC

Technically the same date, but not quite what I wanted. After emailing GitHub and receiving very quick and friendly responses, it turns out that both the timezone offset and the seconds must be omitted:

date: 2014-01-03 07:00

However, in the time that passed, I realised that doing this would actually be short-sighted; it would lock this website into one timezone. Not permanently, perhaps, but one would have to use the same timezone for all posts.

What if, one day, I decide that Perth no longer has the same homely charm, and I grow tired of living in a city where absolutely nothing happens? Heresy, I know, but it's possible.

As an aside, when doing the above, the displayed post dates would be like:

2014-01-03 07:00 Aus

Perhaps using %Z in Jekyll simply takes the first three characters of the tzdata name.

Just stick with UTC.