Search code examples
jekyllliquid

How to check with Liquid if I am in the home page?


I am using Jekyll and I want to have a link to my homepage in all the pages of my site except, of course, in my home page. I thought to put it in the layout.html with a conditional that is true when the actual page is not the home page. Something like this:

  {% if site.baseurl != page.url %}
  <a href="{{ site.baseurl }}">Home</a>
  {% endif %}

But it is not working. Which is the right way to do this? Thanks!


Solution

  • As you home page url is supposed to always be "/".

    You can do :

    {% if page.url != "/" %}
      <a href="{{ site.baseurl }}">Home</a>
    {% endif %}