Section menu items with no name are not rendered

I am migrating my website from Hugo 0.120.4 to 0.139.4. Suddenly some of my menu items don’t appear anymore.

I defined the menu in site configuration like this:

[menus]
[[menus.main]]
    pageRef = '/about'
    weight = 30
[[menus.main]]
    pageRef = '/posts'
    weight = 20
[[menus.main]]
    pageRef = '/phluide'
    name = 'pHluide (pro)'
    weight = 10

And I’m using the Ananke theme with the site navigation template:

{{ if .Site.Menus.main }}
        <ul class="{{ cond (eq $.Site.Language.LanguageDirection "rtl") "pr0 ml3" "pl0 mr3" }}">
          {{ range .Site.Menus.main }}
          <li class="list f5 f4-ns fw4 dib {{ cond (eq $.Site.Language.LanguageDirection "rtl") "pl3" "pr3" }}">
            <a class="hover-white no-underline white-90" href="{{ .URL }}" title="{{ i18n "pageTitle" . }}">
             {{ .Name }}
            </a>
          </li>
          {{ end }}
        </ul>

This gives the following output:

<ul class="pl0 mr3">
          
          <li class="list f5 f4-ns fw4 dib pr3">
            <a class="hover-white no-underline white-90" href="/phluide/" title="pHluide (pro) page">
             pHluide (pro)
            </a>
          </li>
          
          <li class="list f5 f4-ns fw4 dib pr3">
            <a class="hover-white no-underline white-90" href="/about/" title=" page">
             
            </a>
          </li>
          
        </ul>

So:

  • about’s name is blank;
  • posts is not rendered at all;
  • phluide is rendered as expected.

Name | Hugo specifies names should fall back to titles. And everything was fine before migrating. Still is, actually, on my production site.

Front-matter of /about/index.md :

---
title: 'À propos'
description: 'Vous êtes ici.'
date: 2023-11-20T16:37:58+01:00
draft: false
---

Front-matter of /posts/_index.md :

---
title: Articles
description: Professionnels ou non.
---

Front-matter of /phluide/_index.md:

---
title: 'pHluide'
description: 'Page professionnelle'
type: page
layout: single
date: 2023-11-20T16:37:58+01:00
draft: false
toc: true
---

That depends on the template code used to render the menu. You’ll need to share more information.

See Requesting Help.

Let us see your code

Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.

If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.

My bad I forgot, I’ve just added it to the OP.

Yeah, we broke this in v0.123.0:

You have a couple of work arounds until this is fixed:

  1. Provide a name field for each menu entry defined in your site configuration
  2. Define the menu entries in front matter (see docs)
1 Like

This has been fixed and will be available in the next release, v0.140.1.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.