How to modify the secondary navigation template?


I’m locally developping a v3.1.1 Ghost Theme in which I want to use the recently introcuded secondary navigation. The secondary navigation appears correctly in my theme, but I want it to have its own HTML markup.

I know that it is possible to do so for the main navigation by creating a file ./partials/navigation.hbs (called via {{navigation}}).

So, having added {{navigation type="secondary"}} in a template, I’ve created ./partials/navigation-secondary.hbs and ./partials/secondary-navigation.hbs in order to customize the navigation markup.

Unfortunately, none of them works : my secondary navigation keeps using the default navigation template.

Did I miss something ? :thinking:

Thanks a lot in advance if you can help me to resolve this little question.

Hey @Mathieu_Rouault :wave: It’s possible to use a conditional in the ./partials/navigation.hbs file. Eg:

{{#if isSecondary}}
    {{!-- secondary navigation --}}
        {{#foreach navigation}}
            <a class="{{link_class for=(url) class=(concat "nav-" slug)}}" href="{{url absolute="true"}}">{{label}}</a>
    {{!-- primary navigation --}}
    <ul class="nav" role="menu">
        {{#foreach navigation}}
            <li class="{{link_class for=(url) class=(concat "nav-" slug)}}" role="menuitem"><a href="{{url absolute="true"}}">{{label}}</a></li>

Thank you @Kevin ! It works like a charm. :smiley: