Addition to Jekyll: chill_post_url

I use the Jekyll static-site generator plus Octopress’ helper scripts to create this blog.

One of the features about Jekyll is that it checks to make sure that files you refer to are there. This is a pretty sensible choice. When you invoke {% raw %}{% post_url some-file %}{% endraw %}, Jekyll checks to make sure some-file is present and ensures your (likely) typo doesn’t lead to a 404 error. Great! That’s the right call.

But sometimes, I need to ignore that behavior.

Specifically, if you have a large site you might need to “isolate” the post you’re working on. isolate is a command provided by Octopress and what it means is that all the posts that aren’t the “isolated” post are “exiled” and not included in the site build. This means that the site can be rebuilt more quickly, you can quickly iterate on your post, and view it “live” in a development web server as if your entire site were that singular file.

The problem comes in with the “static files” that don’t get “exiled.” These are considered “special” or “top level” files. For example, on my site these are the About, Categories, or Contact pages. In the case that one of these non-exiled pages refers to an exiled page we get an error, as mentioned above.

There didn’t seem to be a way to change this behavior as an argument to the post_url command, so I created a new plugin called chill_post_url. It will send a warning that a file you refer to wasn’t found, but it won’t cause an exception which shuts down the server.

Here’s me defining a Markdown link:

{% raw %} [extension]: {% chill_post_url 2017-09-26-guide-to-developing-chrome-context-menu-applications %} {% endraw %}

Liquid’s template engine will turn the directive into a URL and associate it with the Markdown “named link” called extension. The local web server now warns me:

Warning from Jekyll

The code can be found in my github repo.