Recently when I upgrade the octopress I found the date for post isn’t properly rendered. Then I decided to sit down to spend some time fixing this issue, it turns out to be a very interesting one. I put all of my debug traces here to remind me this journey.
My problem is the date for post doesn’t get rendered.
And when I inspects the relevant source code it shows the time tag only with something like this <time datetime="2014-12-30T06:30:00+01:00" pubdate data-updated="true"></time>
. So where is actually date text ?
The first thing occurred to my mind is probably I screwed up some date formats so that octopress magic date rendering function can’t parse the customized date format ?
So I go to strfti.me to validate my date formats. After trying a few combination, get added to
_config.yml
with something like date_format: "%Y-%m-%d"
, no luck.
So, date format is ok, maybe I don’t get the liquid templating right ? After all, octopress is built on top of Jekyll, and
Jekyll uses the liquid for rendering.
After a few searches, I figure out that the actual rendering work for post date is done in date.html
. Which, is in a
chain of include
with the path: index.html -> article.html -> date.html
.
So the time is there, actually it’s generated by date.html
, get parsed in article.html
. But why it’s missing after rake generate
?
So I do a diff between my previous working version and current one for article.html
:
Well, it’s almost the same except for some irrelevant css stuff.
So Could it be the problem with the date.html
shipped with new octopress version ?
Alright, the date.html
is full of liquid templating which almost makes no sense to me. What should I do ? Hmm, doing a diff with previous working version is still a good start:
It’s the same ! But this is the file responsible for showing the time ! what am I missing here ?
Could it be the change of API in Jekyll for date formatting ? I go to the Jekyll docs to check the date_to_xmlschema
, everything seems fine.
However, when I check the octopress docs, I found something called post.date_time_html
mentioned there which doesn’t appear in our date.html
at all!
According to the docs, using post.date_time_html
will render the following html:
All those spans
are exactly what I’m looking for !
So using these two lines solve my issue, holy cow !
The issue has already been patched with this commit by octopress patch Now, my post date gets back :)