我的default.html
文件夹中有一个名为layouts
的文件。在default.html
中,我想将include
添加到test.html
,这也位于我的布局文件夹中。
我在{% include_relative test.html }%
文件中添加default.html
以包含test.html
。但是,当我这样做时,我收到一个错误
"Liquid Exception: Included file './test.html' not found in
projects/[projectnmae]/layouts/default.html"
我的layouts
文件夹位于我的配置文件中指定的其他位置。如果include_relative
在这里以特殊的方式运作而我没有抓住任何想法?
答案 0 :(得分:4)
您不能将include_relative
标记与layouts文件夹中的任何文件一起使用。您只能在页面或帖子上使用include_relative
。
答案 1 :(得分:3)
布局代码在页面/后期渲染的上下文中执行,include_relative
是相对于此页面或帖子计算的,而不是从布局本身计算的。
在调试器中跟踪此错误表明include_relative
尝试加载/home/user/www/test/_posts/test.html
而不是/home/user/www/test/_layouts/test.html