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

那年仲夏 提交于 2020-01-23 03:35:10

问题


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.


回答1:


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"



回答2:


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



来源:https://stackoverflow.com/questions/49609857/why-is-the-post-layout-missing-from-so-many-themes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!