为什么这么多主题缺少“职位"布局? [英] Why is the 'post' layout missing from so many themes?

查看:103
本文介绍了为什么这么多主题缺少“职位"布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用WordPress插件"WordPress to Jekyll Exporter"将WordPress博客转换为Jekyll博客.所有帖子都包含以下内容:

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

但是除了默认的minima主题之外,我测试过的所有主题显然都没有这种post布局,因为对于每篇文章,我都从Jekyll服务器收到类似这样的错误消息:

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:

构建警告:在中请求布局发布" _posts/2015-11-07-the-case-for-nested-methods-in-ruby.md不存在.

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?

我的高级目标是尝试使用除极小值以外的主题,以找到比默认主题minima更具吸引力的东西.

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

推荐答案

Jekyll没有标准的布局命名方式,这具有灵活性的优点,但有时会引起混淆.

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

每个主题都可以创建自己的布局,因此您会发现不断变化的主题并不能按您预期的方式工作,实际上,大多数情况都不会,因为通常您会找到defaultpagepost布局,但是当您尝试其他主题时,它们的布局可能会以不同的方式命名.

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.

minimum-mmistakes 主题为例,最受欢迎的主题,它具有所有这些布局:

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

如果您只是在config中更改主题名称,我敢打赌它不会使用所有这些布局.

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

这就是为什么您需要根据每个主题要求自定义网站.

您无需在每个帖子中都指定主题布局,通常在config中将其设置为默认的主题更为简单,在这种情况下,每个帖子都会使用该主题布局:

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"

这篇关于为什么这么多主题缺少“职位"布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆