Search code examples
htmlnavigationtwiggrav

Grav - skip homepage in menu


I am making my first Grav website.

I'm trying to creating a navigation menu and I'd like it to display links to all visible pages but not the homepage. At the moment the homepage comes up as the first link, is there a way to skip over it?

<ul>
      {% for page in pages.children.visible %}
          {% set current_page = (page.active or page.activeChild) ? 'active' : '' %}
          <li class="{{ current_page }}">
              <a href="{{ page.url }}">
                  {% if page.header.icon %}<i class="fa fa-{{ page.header.icon }}"></i>{% endif %}
                  {{ page.menu }}
              </a>
          </li>
      {% endfor %}
</ul>

Solution

  • As seen in the Page API

      {% for page in pages.children.visible if not page.home() %}