Search code examples
postlayoutjekylljekyll-theme

Why is the 'post' layout missing from so many themes?


I used the WordPress plugin "WordPress to Jekyll Exporter" to convert my WordPress blog to a Jekyll blog. All posts had front matter that included:

layout: post

But all the themes I've tested other than the default minima theme apparently do not have this post layout, because I get error messages like this from the Jekyll server for every post:

Build Warning: Layout 'post' requested in _posts/2015-11-07-the-case-for-nested-methods-in-ruby.md does not exist.

What's happening here? Are all the themes intended for web sites that are not blogs?

Is there a simple fix for this?

My higher level goal is to experiment with themes other than minima to find something a bit more attractive than the default minima theme.


Solution

  • Jekyll does not have a standard way of naming layouts, this has the benefit of flexibility but it can cause confusion sometimes.

    Every theme can create their own layouts, so you will find that changing themes, doesn't work the way you expected, in fact, most don't because generally you will find default, page, and post layouts, but when you try another theme, their layouts would probably be called differently.

    Take for example the minimal-mmistakes theme, one of the most popular themes out there, it has all these layouts:

    _layouts/
      ├── archive.html
      ├── archive-taxonomy.html
      ├── categories.html
      ├── category.html
      ├── collection.html
      ├── compress.html
      ├── default.html
      ├── home.html
      ├── posts.html
      ├── search.html
      ├── single.html
      ├── splash.html
      ├── tag.html
      └── tags.html
    

    if you just change your theme name in config, I bet it won't use all of those layouts.

    This is why you need to customize your site following each theme requirements.

    Note

    You don't need to specify theme layout in each post, it is generally simpler to set it as a front matter default in config, and in this case, every post would use that:

    defaults:
      -
        scope:
          path: ""
          type: "posts"
        values:
          layout: "post"