Why does conditional include stop working in Jekyll unless I add non-white
space character(s)?
My Jekyll-based web site suddenly stopped including the Google Analytics
script blog. Yesterday, it was working (the script block was on all
pages), but today, after I uploaded a new post, the script block was
uniformly gone from all pages.
I'm hosting my site on GitHub pages, so in order to troubleshoot, I wanted
to reproduce the issue on my local machine. It turned out that I was
running old versions of Ruby and Jekyll on my local machine, so I updated
Ruby and installed the GitHub Pages Gem in order to ensure that my local
environment matched GitHub pages:
gem install github-pages
That enabled me to reproduce the issue. Now, even when I ran
jekyll serve --safe
the Analytics script blog wasn't included in any page.
After much troubleshooting, I finally figured out that if I put any sort
of non-white space character(s) in my JB/analytics file, between the
google case and the include directive, it worked.
Thus, this works, in the sense that when the --safe switch is on, the
script block in JB/analytics-providers/google is included:
{% case site.JB.analytics.provider %}
{% when "google" %}.
{% include JB/analytics-providers/google %}
(notice the period character after {% when "google" %}).
However, this doesn't work - even with the --safe switch, the contents of
include JB/analytics-providers/google is never included:
{% case site.JB.analytics.provider %}
{% when "google" %}
{% include JB/analytics-providers/google %}
While I have a workaround, I'd much appreciate an explanation of this
behaviour.
No comments:
Post a Comment