Jekyll 公共页面,post 配置

Jekyll common page, post config

我在任何地方都找不到这个解决方案,我不知道是否可行,但是否有机会设置通用的 Jekyll post 配置,至少是其中的一部分。

我试过几种方法...

通过包含作为降价和html

post_config.md

---
layout: blog
bodyClass: blog
excerpt_separator: <!--more-->
permalink: blog/:categories/:year/:month/:day/:title.html

02-08-1016-post.md

{% include post_config.md %}
title: Hello.
author: Some Dude.
---

默认 来自主配置

#Defaults
defaults:
  scope:
    path: '_posts'
    type: 'pages'
  values:
    layout: blog
    bodyClass: blog
    excerpt_separator: <!--more-->
    permalink: blog/:categories/:year/:month/:day/:title.html

来自主模板的 inheritace

没有任何效果...可行吗?有人可以帮忙吗?

查看 Jekyll Configuration guideFront Matter defaults 部分。

具体来说,您可以在 _config.yml 文件中定义一个 defaults 键,列出每个文件的默认值。您可以缩小范围并为特定类型的帖子指定默认值。

这是一个例子:

defaults:
  -
    scope:
      path: ""
      type: "posts"
    values:
      layout: "my-site"
  -
    scope:
      path: "projects"
      type: "pages" # previously `page` in Jekyll 2.2.
    values:
      layout: "project" # overrides previous default layout
      author: "Mr. Hyde"

With these defaults, all posts would use the my-site layout. Any html files that exist in the projects/ folder will use the project layout, if it exists. Those files will also have the page.author liquid variable set to Mr. Hyde.

尝试一下,如果仍然无法正常工作,请尝试比说 "nothing works" 更具体。尝试更具体地说明您正在做的事情、您期望发生的事情以及实际发生的事情。祝你好运。