How to pass {

后端 未结 2 1812
心在旅途
心在旅途 2021-02-18 22:48

I am trying to rebuild a blog in Jekyll and I have stubled upon a simple task.

Provided I have the following set of templates:

default.html:

2条回答
  •  暖寄归人
    2021-02-18 23:00

    You can't do this with a capture, but you can using an include. Every level of the page hierarchy can override the head key to point to a different include file as required. This example wraps the include with a condition so if no head key is specified the page will still generate.

    default.html

    {% if page.head %}
      {% include {{ page.head }} %}
    {% endif %}
    
    {{ content }}
    

    frontpage.html

    ---
    layout: default
    head: header1.html
    ---
    
    {{ content }}
    

    _includes/header1.html

    (Frontpage header content)
    

提交回复
热议问题