Jekyll IF statement for 'IF index (home) and NOT paged'?

jekyll, liquid

Solution

Got it!

UPDATE: This doesn't work, if you don't yet have enough posts for pagination. That is, it only works if you have at least `page1` and `page2`.

As you may already know, Jekyll supports pagination. So, to target just the Index/Home page (and specifically only the first page, i.e. `page1` and NOT `page2`, `page3` ...), you can use this:

{% if paginator.next_page == 2 %}

    <div id="welcome">Hello, welcome to my blog!</div>

{% endif %}

`{% if paginator.next_page == 2 %}` tells Jekyll to check if the next page of the pagination is `page2` (i.e. the current page is `page1`) and show the specified content.

This works best of all:

{% if paginator.previous_page %}
{% else %}

    <div id="welcome">Hello, welcome to my blog!</div>

{% endif %}

Untested, but `{% if paginator.previous_page == 0 %}` might work as well.

Problem

As you may know Jekyll uses Liquid tags, and the Liquid templating engine has support for `If / Else / Unless` statements. Does anyone know how to show a specific content only on the 'homepage` (& NOT paged)?

Original source