条件模板是否覆盖了Jekyll框架的一部分?

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

我有兴趣使用Jekyll来托管许多共享许多信息和Web界面的商业网站。因此,我很好奇Jekyll是否可以轻松支持我要问的问题。

如果这是另一个网站平台,如WordPress,Magento等。等等……我可能会像这样为我的网站设置默认模板:

tpl/default/header.html
tpl/default/footer.html
tpl/default/privacy-policy.html
tpl/default/pricing.html
tpl/default/contact/map.html
tpl/default/contact/form.html

然后为每个与我签约的公司,我都会为他们建立一个名为tpl/<businessname>/的文件夹。然后,平台将使用tpl/<businessname>/目录中的所有html文件创建一个网站。每当tpl/<businessname>目录中不存在模板时,平台将使用tpl/default/目录中的相应模板。

例如,Bicycle Shop想要我的网站。我继续创建:

tpl/bicycyle-shop/contact/map.html

然后在我的布局文件中,我可能会这样拨打电话:

<?php
define('ORG','bicycle-shop');
put_tmpl('contact/form.html'); // this will use tpl/default/contact/form.html
put_tmpl('contact/map.html'); // this will use tpl/bicycle-shop/contact/map.html

function put_tmpl($tplname) { 
    if(file_exists('tpl/'.ORG.'/'.$tplname))
        include('tpl/'.ORG'.'/'.$tplname);
    else
        include('tpl/default/'.explode('/',$tplname)[count(explode('/',$tplname))-1]);
}
?>

我很好奇在Jekyll中如何实现这种行为?


ADDITIONAL

我想到的一种方法是让_config.yml的变量如:

tmpl:
  home: tpl/default/header.html
  pricing: tpl/default/pricing.html
  ...etc...

然后每个公司的_config<businessname>.yml会覆盖相应的tmpl变量。那会是吉柯尔公约吗?还是Jekyll提供了一些更好的选择?

jekyll
1个回答
0
投票

有主题...您只需在配置中将主题安装为gem。当您需要覆盖主题文件时,只需将该文件放在_layouts或_includes目录中即可。

超级简单。

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