Back to WordPress

Last August I outlined some new rules for myself when it comes to blogging and they have worked well. The only thing outlined which I haven’t adhered to is “no categories” — there’s just too much differently themed content on this site to make it sane to navigate without them.

The “no categories” rule fell into the “get out of your own way” bucket. I’ve reached a point where I need add a sister rule, the “get out of my way” rule, the contents of which would read something like: “If you think about writing a post then remember some pain-point in the process which makes you reluctant to do so, get rid of the pain-point”. For me, that pain-point has become Jekyll.

Read on, there’s more »

Jekyll: Create a list of all posts in the same category

Let’s take a look at how to create a list of all of the posts in the same category as the one currently being viewed, bearing in mind three requirements:

  1. If the post has more than one category, we want to create a list for each category.
  2. We don’t want to show the list if there is only one post in the category (the one being viewed).
  3. We don’t want to include the post who’s page is currently being viewed within the list.

Read on, there’s more »

Jekyll: Display the full post unless a custom excerpt is specified

The homepage of this site lists the full content of each post by default. An excerpt is shown only if a post contains <!--more-->, which is the default excerpt separator in Jekyll.

Describing this functionality in prose looks something like this. For each post that is looped through, check it’s content for the excerpt separator. If found, then show all the content up until the separator, then a read more link. If not, show the full content of the post.

Translating the above to liquid results in the following snippet within the posts loop.

{% raw %}

{% if post.content contains site.excerpt_separator %}
  {{ post.excerpt }}
  <a href="{{ post.url }}">Read more</a>
{% else %}
  {{ post.content }}
{% endif %}

{% endraw %}

If <!--more--> isn’t to your liking, excerpt_separator can be configured globally in _config.yml.