Reputation: 31
Hey so I have built a multi-language website and I only want certain pages to show in the top navigation but they are showing in the navigation
This is what I have in my header.html
{% assign pages = site.pages | sort: "nav-order" %}
{% for p in pages %}
{% if p.language == page.language %}
<li><a class="tx--upper {% if p.url == page.url %}is-active{% endif %}" href="{{ p.url | prepend: site.baseurl }}">{{ p.title }}</a></li>
{% endif %}
{% endfor %}
And this is what I have in my yaml fontmatter for the page I want to be shown in the top navigation (about.html)
---
title: About
language: en
nav-order: 1
---
And this is what I have on my page that I don't want shown in top navigation (404.html)
---
language: en
nav-order:
---
But show to I get it to check if nav-order
is empty to not display in the top nav ? I have tried a if
statement to check the assign pages !== null
and also did a exclude from what I could find online but nothing has worked.
Upvotes: 1
Views: 377
Reputation: 52799
If if you only want to print page with a nav-order:
set, you can just complement your condition like this :
{% if p.language == page.language and p.nav-order %}
Upvotes: 1