Ordering & limiting elements in menu

Hello all!

Complete amateur here, trying to build his own website and learn something in the proces.
I’ve been tinkering with Hugo these last few days and I’m pretty happy with the progress I’ve made so far.

One of the partials I made is a menu that first lists some series (for photographs) and then some tags associated with those posts.

But I’d like my menu to be structured somewhat better: the series I’d like to be chronological (so if I publish a new photo series, it’s on top), and I’d like to limit the tags in the menu to the 5 (or so) most used ones.

But I’m somewhat at a loss at how to go about this with the code I have right now. Any tips or resources to look into?

        <ul class="series">
    <!-- Range over series -->
            {{ range $name, $taxonomy := .Site.Taxonomies.series }}
            <li><a href="/series/{{ $name | urlize }}">{{ $name }}</a></li>
            {{ end }}

        <ul class="tags">
    <!-- Range over top 5 tags -->
            {{ range $name, $taxonomy := .Site.Taxonomies.tags }}
            <li><a href="/tags/{{ $name | urlize }}">{{ $name }}</a></li>
            {{ end }}

We can’t see the output, so we don’t know what you are getting that doesn’t match what you want. Please share your repo and follow the advice at Requesting Help. :slight_smile:

My bad!

Repo can be found here.

1 Like