Jekyll 包含来自外部文件的变量
Jekyll include variables from external file
使用 Jekyll,我知道您可以在 include 行中包含一个变量,如下所示:
---
layout: default
testVar: test1
---
{% include test_block.html testDivContent=page.testVar %}
是否可以包含另一个从外部文件传入变量内容(在本例中为 testVar: test1
)的文件?
所以像
---
layout: default
---
{% include testVar_file.html %}
{% include test_block.html testDivContent=page.testVar %}
其中 testVar_file.html 包含变量 testVar: test1
您可以使用 data file.
_数据/testVar_file.yml
testVar: test1
index.md
---
layout: default
---
{% include test_block.html testDivContent=site.data.testVar_file.testVar %}
使用 Jekyll,我知道您可以在 include 行中包含一个变量,如下所示:
---
layout: default
testVar: test1
---
{% include test_block.html testDivContent=page.testVar %}
是否可以包含另一个从外部文件传入变量内容(在本例中为 testVar: test1
)的文件?
所以像
---
layout: default
---
{% include testVar_file.html %}
{% include test_block.html testDivContent=page.testVar %}
其中 testVar_file.html 包含变量 testVar: test1
您可以使用 data file.
_数据/testVar_file.yml
testVar: test1
index.md
---
layout: default
---
{% include test_block.html testDivContent=site.data.testVar_file.testVar %}