Menu don't get URL correct (only 1 menu item; latest Hugo)

I’ve used the following menu in yaml

menus:
  main:
    - identifier: home
      name: Home
      pre: <i aria-hidden> 🏡 </i>
      pageRef: /
      weight: 10
    - identifier: blog
      name: Blog
      pre: <i aria-hidden> 🧑‍💻 </i>
      pageRef: /blog
      weight: 20
    - identifier: welcome
      name: Welcome
      pre: <i aria-hidden> 🦄 </i>
      pageRef: /welcome
      weight: 30

And following partial in Menu templates

{{- range site.Menus.main }}
  <a {{ with .Params.class -}} class="{{ . }}" {{ end -}} href="{{ .URL }}">
    {{ .Name }}
  </a>
{{- end }}

In both partials Home and Blog urls generated but not the /welcome

Tested in the latest version of Hugo too. Same issue.

Thanks

1 Like

It showed up on my end. Delete the public directory and your browser cache/cookies and try again.

<nav role="navigation"><select onchange="this.value&amp;&amp;(window.location.href=this.value)">
<option value="https://dumindu.github.io/nu_1/" selected="">🏡 Home</option><option value="https://dumindu.github.io/nu_1/blog/">🧑‍💻 Blog</option><option value="https://dumindu.github.io/nu_1/">🦄 Welcome</option></select></nav>

As your attached code shows,

  • Home: baseURL
  • Blog: baseURL/blog
  • Welcome: baseURL but it should be baseURL/welcome
1 Like

See docs:
https://gohugo.io/configuration/menus/#pageref

The logical path of the target page.

Do this: pageRef: /page/welcome

1 Like

Thanks @jmooring as always

1 Like

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