Jekyll - 如何仅为主页设置YAML前端默认设置?

问题描述 投票:0回答:1

我目前正在使用Jekyll开发个人博客(使用this blog post进行简单的设置指南)。我正在尝试重新使用HTML文件,以便一个网址"/"显示一些文本,而另一个网址"/posts"显示略有不同的内容。要做到这一点,我试图在Font Matter Default设置一个_config.yml,它只适用于其中一条路径,即主路径"/"

这是我用来设置Font Matter Default的代码:

# site defaults (https://jekyllrb.com/docs/configuration/)
defaults:
  - scope:
      path: ""
    values:
      display_num_posts: 5

我面临的问题是path: ""适用于所有页面,所以我的变量display_num_posts将在我的HTML文件使用的每个页面(5"/")上设置为"/posts"

我的问题:如何设置仅包含主页的路径?网址中没有额外的"/posts"

我试过在https://jekyllrb.com/docs/页面上搜索,但找不到答案。我也试过设置path: "/",但那条路径根本不匹配任何网址。

jekyll yaml-front-matter
1个回答
0
投票

显然,这可以通过将path设置为基本index.html文件来完成,如下所示:

# site defaults (https://jekyllrb.com/docs/configuration/)
defaults:
  - scope:
      path: "index.html"
    values:
      display_num_posts: 5

我发现这在this blog post上是可能的。

希望这有助于帮助我的人。

© www.soinside.com 2019 - 2024. All rights reserved.