Why is the 'post' layout missing from so m

2019-04-16 05:43发布

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.

2条回答
在下西门庆
2楼-- · 2019-04-16 06:18

I don't´know which themes are you talking about, but you can find themes here:

http://jekyllthemes.org Most themes i look into have the post layout.

if you really need and can´t find it, you can create your own template for posts, by adding the post.html filo into the template folder, and simply call the default layout.

---
layout: default
---

perhaps you could add the link to the themes you are talking about and if they are on Github, you can always file an Issue on that theme.

here you call call a new Issue for Minima:

https://github.com/jekyll/minima/issues

查看更多
迷人小祖宗
3楼-- · 2019-04-16 06:21

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"
查看更多
登录 后发表回答