Jeric Dy
Life is a Game
ProjectsPublicationsResume
HomeAll Projects Mega Man Legends: OML Sworld Mega Man Legends (SP)

Me

Blog Publications Contact Resume

I have decided to migrate my comments section from Blogger's to Disqus'. I also wanted to preserve all my previous comments, so I've placed a button at the bottom of the page to show the Blogger comments. If I apply the button to all my posts, even my new posts will have the Blogger comment option (which I don't want). So I've set a date, say January 1, 2016, everything before the said date will have the button appear.

I soon realized I can't compare the page's timestamp to a hard-coded timestamp

	
		{% if page.date < "2016-01-01 00:00:00 +0000" %}
			...stuff...
		{% endif %}
	

I have tried every possible permutation even ISO format. I always end up with the error:

	
		Liquid Exception: Liquid error (line 27): comparison of Time with Liquid::Token failed in _layouts/post.html error:
		Error: Liquid error (line 27): comparison of Time with Liquid::Token failed
		Error: Run jekyll build --trace for more information.
	

It turns out, I should have assigned the timestamp to a page variable before comparing it. This way, jekyll will cast it as a timestamp instead of string.

	
		blogger-timestamp: 2016-01-01 00:00:00 +0000
		---
		{% if page.date < blogger-timestamp %}
			...stuff...
		{% endif %}
	

I initially hard-coded it just to do a quick test, but ended up spending about an hour trying to figure out how to compare timestamps in Jekyll. Only to realize it's because I am comparing a timestamp to a string!. Oh well, all's well that ends well, I guess.