New: Learn Statamic on Laracasts!

We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

Question regarding navigation logic

Stefan Kempf April 13, 2021 by Stefan Kempf

Dear friends of Statamic,

I'm currently at the beginning of the adventure teaching myself statamic. Please bear with me, I'm not that experienced.

While building a navigation like in I'm coming across a behaviour I don't understand.

My pages tree look like this:

  • home
  • musicians
    • marc
    • cedric
  • projects
    • album
    • single

I have the following code for the second level navigation:

{ nav:collection:pages :from="segment_1" }}
        {{ if ! no_results}}
            <li><a class="text-gray-100 text-m p-6 block" href="{{ url }}">{{ title }}</a></li>
        {{ /if }}
{{ /nav:collection:pages }}

my problem

When I'm on the homepage, the second level navigation shows me two entries, musicians and projects. As far as I understand (which is obviously wrong), those two entries are in segment_1 so on home, no sub navigation should be shown.

Can somebody point me into the right direction of what I'm doing wrong?


Answered by Stefan Kempf!
>>>>>>> Answered <<<<<<<
5 Replies