I have a Jekyll blog hosted on GitHub Pages that I recently updated to HTTPS. In doing so, I discovered that recent updates to Jekyll were causing my blog to no longer build properly. Running a local install I kept encountering the following error:
Liquid Exception: no implicit conversion of Integer into String in /_layouts/default.html
After some trial and error I was able to identify the following posts as causing the problem:
2003-09-21-100.md
2004-02-10-10000.md
2004-02-28-228.md
2004-09-10-1.md
2004-10-10-1969.md
2004-11-06-1896.md
2005-05-14-616.md
These are all old Wordpress posts that I imported into Jekyll, and as you can see, they all have numbers as titles. It didn't cause build problems on earlier versions of Jekyll however. While I could rename all of these old posts, it would be a bit of a pain since I would have to update any Disqus comments URLs, and any existing links on the web to those posts would be broken. Does anyone know if there is an easier way to fix this problem? Thanks!
The real problem is that the escape
filter isn't able to handle numbers, for example:
{{ 1618 | escape }}
Throws:
/tmp/vendor/ruby/2.3.0/gems/liquid-4.0.0/lib/liquid/standardfilters.rb:36:in `escapeHTML': no implicit conversion of Fixnum into Strin
g (TypeError)
As you are using escape
in titles: <title>{% if page.title %}{{ page.title | escape }}{% else %}{{ site.title | escape }}{% endif %}</title>
and many titles has only numbers, then it will fail.
A quick hack to fix it is to convert them to strings before using the escape
filter, using the capture
variable tag:
Captures the string inside of the opening and closing tags and assigns it to a variable. Variables that you create using capture are stored as strings.
In _includes/head.html
:
{% capture mytitle%}{{page.title}}{%endcapture%}
<title>{% if mytitle %}{{ mytitle | escape }}{% else %}{{ site.title | escape }}{% endif %}</title>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With