2 minute read

Posts

Post files must be located in the _posts folder of your Jekyll site. This docuemnt if itself an example of a post, setup using the theme Minimal Mistakes.

The name of a post file must start with a date followed by a hyphen (“-“) using this format:

YYYY-MM-DD-file_name.md

_config.yml and front matter

Posts are mostly used for blogs that are published over time and should have both date, title and preferably also an excerpt key in the post file front matter (otherwise the first paragraph is used as excerpt - see the Jekyll document on Posts):

title:  "Posts in Jekyll: 1. basics"
excerpt: "How to set front matter in Jekyll posts and basic options for layout and content using the theme Minimal Mistakes."
date: 2024-09-20 12:13:03 +0200
last_modified_at: 2024-09-20 12:13:03 +0200

The keys for date and last_modified_at are optional, but I prefer to include them to keep track of when I made the latest changes. For more details on displaying post dates see the Minimal Mistakes posts Layout: Post Date Enabled and Layout: Post Date Disabled.

For posts, the author of the theme Minimal Mistakesrecommends the following settings in _config.yml (I added the show_date key):

defaults:
  # _posts
  - scope:
      path: ""
      type: posts
    values:
      layout: single
      author_profile: true
      show_date: true
      read_time: true
      share: true
      related: true

Transferred to the front matter of the posts document itself this becomes:

layout: single
author_profile: true
show_date: true
read_time: true
share: true
related: true

Combined with the post local keys, the complete front matter then becomes:

layout: single
author_profile: true
read_time: true
share: true
related: true
title:  "Posts in Jekyll: 1. basics"
excerpt: "How to set front matter in Jekyll posts and basic options for layout and content using the theme Minimal Mistakes."
date:   2024-09-20 12:13:03 +0200
last_modified_at: 2024-09-20 12:13:03 +0200

Key values set in the posts file front matter has precedence over values set in _config.yml if a key:value pair is set in both.

Posts usually also have keys for categories and tags. Each post can belong to multiple categories and have multiple tags. In the theme Minimal Mistakes, the categories and tags are shown towards the end of a post.

Table of content

To set a table of content in a post, follow the same syntax as outlined for pages.

Resources

Jekyll page on posts

Minimal Mistakes - posts

Minimal Mistakes - layout: post date enabled

Minimal Mistakes - layout: post date disabled