Tom*_*son 3 relative-path include jekyll
我有一个名为default.html
我的layouts
文件夹中。在中default.html
,我想添加一个相include
对于的相对对象test.html
,它也在我的layouts文件夹中。
我{% include_relative test.html }%
在default.html
文件中添加include test.html
。但是,当我这样做时,我得到一个错误,指出
"Liquid Exception: Included file './test.html' not found in
projects/[projectnmae]/layouts/default.html"
Run Code Online (Sandbox Code Playgroud)
我的layouts
文件夹确实位于配置文件中指定的其他位置。有什么想法include_relative
可以以一种我不掌握的特殊方式起作用吗?
布局代码在页面/帖子渲染的上下文中执行,并且include_relative
相对于此页面或帖子计算,而不是从布局本身计算。
在调试器中跟踪此错误显示include_relative
尝试加载/home/user/www/test/_posts/test.html
而不是/home/user/www/test/_layouts/test.html