2
votes

I'm building my second Jekyll site and I'm trying to make the page layout pull in different includes based on variables.

For example, in download.md:

layout: page  
form: "free"  
sidebar: "terms"

With this, the site will no longer compile. It says

Liquid error (line 17): wrong number of arguments (4 for 3).

Line 17 is the first if statement in the example below.

How should I set up these includes?

<article class="s-article t-twocol__article">
  <header class="s-article__header">
    <h1 class="s-article__title">{{ page.title }}</h1>
    <h4 class="s-article__lede">{{ page.lede }}</h4>
  </header>
  <div class="s-article__content">
    {% if {{page.form}} == "full" %}
      {% include c-form--full.html %}
    {% endif %}
    {% if {{page.form}} == "free" %}
      {% include c-form--free.html %}
    {% endif %}
    {{ content }}
  </div>
</article>
2

2 Answers

2
votes

You're not looking at the right place. "Line 17" is from some liquid parsing point of view and not related to your code line numbering.

The real problem is that you try to use limit: n on the where filter which is not valid. The limit: n (as well as offset: n) can only be used on for in loop.

_layout/page.html - line 47

{% assign cards = site.posts | where:"type","premium" limit:1 %}
  {% for card in cards %}
    ..

Must be changed to :

{% assign cards = site.posts | where:"type","premium" %}
  {% for card in cards limit:1 %}
    ..

And you have three more occurrences in index.html at lines 21, 25 and 43, where you can move the limit: n from the where filter to the for loop.

0
votes

Change:

{% if {{page.form}} == "free" %}
{% if {{page.form}} == "full" %}

To:

{% if page.form == "free" %}
{% if page.form == "full" %}