Jekyll Spaghetti Code

So, it’s probably just because I’m a WordPress guy, but after using Jekyll for a while, I feel like it’s primitive templating system breeds unmaintainable spaghetti code.

I have lots of code duplicated in funny places, which is bad.

I have to resort to all sorts of tricks to minify my output, otherwise any line with nothing but a Liquid tag (there are many lines like this) will output an indented blank line.

Creating an ATOM feed that includes everything I’m used to including is a nightmare.

---
layout: minify-xml
---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:georss='http://www.georss.org/georss' xmlns:thr='http://purl.org/syndication/thread/1.0' xmlns:gd='http://schemas.google.com/g/2005' xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">
  {% if site.url %}
        {% assign siteURL = site.url %}
    {% else %}
        {% assign siteURL = site.root %}
    {% endif %}
    {% if site.guid %}
        <id>{{ site.guid }}/</id>
    {% else %}
        <id>{{ siteURL }}/</id>
    {% endif %}
    <updated>{{ site.time | date_to_xmlschema }}</updated>
    <link rel="self" type="application/atom+xml" href="{{ siteURL }}/atom.xml"/>
    <link href="{{ siteURL }}/"/>
    <title type="text">{{ site.title }}</title>
    {% if site.license %}
        <link href="{{ site.license }}"  rel="license" type="text/html"/>
    {% endif %}
    {% if site.license contains '//creativecommons.org/licenses/' %}
        <creativeCommons:license>{{ site.license | XMLURL }}</creativeCommons:license>
    {% endif %}
    {% if site.icon %}
        <icon>{{ site.icon | XMLURL }}</icon>
    {% else %}
        <icon>{{ siteURL }}/favicon.ico</icon>
    {% endif %}
    <author>
        <name>{{ site.author }}</name>
        <email>{{ site.email | xml_escape }}</email>
        <gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://gravatar.com/avatar/{{ site.email | md5 }}?s=512'/>
    </author>
    <logo>http://gravatar.com/avatar/{{ site.email | md5 }}?s=144</logo>
    {% for post in site.posts limit:8 %}
        {% unless post.hide %}{% unless post.layout == 'page' %}
    {% if post.guid %}
        {% assign guid = post.guid %}
    {% else %}
        {% assign guid = siteURL + post.id %}
    {% endif %}
         <entry>
                <id>{{ guid }}</id>
                <updated>{{ post.date | date_to_xmlschema }}</updated>
                <title>{{ post.title | xml_escape }}</title>
                <link href="{{ siteURL }}{{ post.url }}" />
                <link href="{{ siteURL }}{{ post.url }}" rel="alternate" type="text/html" />

                {% if post.disqus.siteid and post.disqus.postid %}
                    {% disqus_thread_rss post.disqus.siteid post.disqus.postid %}
                {% else %}
                    {% if post.blogger.siteid and post.blogger.postid and post.blogger.comments %}
                        {% blogger_thread_rss post.blogger.siteid post.blogger.postid %}
                    {% endif %}
                {% endif %}

                {% if post.author %}
                    {% if post.author.name %}
                        <dc:creator>{{ post.author.name }}</dc:creator>
                    {% endif %}
                    <author>
                        {% if post.author.name %}
                        <name>{{ post.author.name }}</name>
                        {% endif %}
                        {% if post.author.email %}
                        <email>{{ post.author.email | xml_escape }}</email>
                        {% endif %}
                        {% if post.author.url %}
                        <uri>{{ post.author.url | XMLURL }}</uri>
                        {% endif %}
                        {% if post.author.image %}
                        <gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='{{ post.author.image | XMLURL }}'/>
                        {% endif %}
                    </author>
                {% endif %}
                <content type="html">{{ post.content | feedfilter | xml_escape }}</content>
                {% if post.thumbnail %}
                <media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='{{ post.thumbnail | XMLURL }}'/>
                {% endif %}
                {% if post.location %}
                    {% if post.location.name %}
                        <georss:featurename>{{ post.location.name }}</georss:featurename>
                    {% endif %}
                    {% if post.location.latitude and post.location.longitude %}
                        <georss:point>{{post.location.latitude}} {{post.location.longitude}}</georss:point>
                        <geo:lat>{{ post.location.latitude }}</geo:lat>
                        <geo:long>{{ post.location.longitude }}</geo:long>
                    {% endif %}

{% comment %}
                    {% if post.location.box %}
                        <georss:box>{{ post.location.box | join ' ' }}</georss:box>
                    {% endif %}
{% endcomment %}

                {% endif %}
            </entry>
     {% endunless %}{% endunless %}
 {% endfor %}
</feed>

One of the most fursturating things is that, since Jekyll has no standard way to name config variables or post metadata, it is almost impossible to share code between two different Jekyll sites.

Maybe posts will embed geo data using Keith Marran’s technique, or maybe using the Jekyll-Mapping technique. A template has no way of knowing, and dealing with both situations takes more than twice the code.

ugh.

 
4
Kudos
 
4
Kudos

Now read this

Game Boy Camera

Recently, I’ve taken to shooting photos using an old Game Boy camera. I am primarily using a Game Boy Color to shoot, as the screen provides more contrast than the original “Grey Brick” Game Boy. I think the Game Boy Light would probably... Continue →