jekyll 内の液体変数にはパラメーターが含まれます
概要
_includes に jekyll パーシャルがあり、そのコンテンツの周りに色付きの div をラップしています。部分 (callout.html) は次のようになります。
<div markdown="1" class="callout">
{{ include.content }}
</div>
そして、test.mdで次のように呼び出します。
{% include callout.html content="Content to be filled with a URL: {{ site.baseurl }}/img/test.png" %}
ただし、これにより Liquid はエラーをスローします。
Liquid Exception: Invalid syntax for include tag: ...
" Valid syntax: {% include file.ext param='value' param2='value' %} in
bundler: failed to load command: jekyll (/usr/local/lib/ruby/gems/2.6.0/bin/jekyll)
この問題は、content パラメータに {{ site.baseurl }} を含めたことが原因だと思います。
この制限を回避するにはどうすればよいですか?
解決策
https://translate.google.com/translate?hl=ja&sl=en&tl=ja&u=https://jekyllrb.com/docs/includes/#passing-parameter-variables-to-includes
投稿後すぐに、Jekyll ドキュメントで答えを見つけました。
content パラメータの値は、キャプチャを使用してインクルードに渡す前に、変数として個別に保存する必要があります。上の例の場合:
{% capture callout_content %}
Content to be filled with a URL: {{ site.baseurl }}/img/test.png
{% endcapture %}
{% include callout.html content=callout_content %}