在Jekyll中,是否必须在_config.yml中定义所有变量?

时间:2014-10-19 01:10:49

标签: jekyll

在我的Jekyll _config.yml文件中,我有:

...
test1: hello
...

在我的index.html文件中,我有

...
<h1>{{ site.test1 }}</h1>
...

当我的网站建立时,在_site / index.html中,我现在有

...
<h1>hello</h1>
...

这是我想要做的:在我的_config.yml文件中:

...
test1: hello
@include _config2.yml ### this is not possible, but I'd like to do this!
...

然后,在_config2.yml:

...
test2: world
...

在index.html中,

...
<h1>{{ site.test1 }}, {{ site.test2 }}</h1>
...

将在_site / index.html中生成:

当我的网站建立时,在_site / index.html中,我现在有

...
<h1>hello, world</h1>
...

我试图弄清楚如何做到这一点,我的想法是我有一个包含数十个变量的单页网站,为了我的编辑,我希望他们能够在单独的.yml文件中。

干杯,

阿尔伯特

1 个答案:

答案 0 :(得分:0)

Jekyll提供了使用您的网页和帖子中可用的数据文件的选项。这对他们来说是一个完美的案例。

此处提供更多信息:http://jekyllrb.com/docs/datafiles/