adityatelange / hugo-PaperMod

A fast, clean, responsive Hugo theme.
https://adityatelange.github.io/hugo-PaperMod/
MIT License
9.72k stars 2.62k forks source link

[BUG] menus not rendered in recent hugo versions, starting with 0.125.0 #1505

Closed Cephra closed 5 months ago

Cephra commented 5 months ago

Starting with hugo version 0.125.0, the menus in my blog aren't rendered unless I explicitly add the menu to the .md file.

  1. Have a section in content such as /about or even simply search.md
  2. Render the blog
  3. Visit the blog
  4. about and search are not showing up in the menu.

With my local hugo installation (hugo v0.123.7+extended), everything works as expected. The menu items are rendered.

adityatelange commented 5 months ago

Can't reproduce this issue. See generator meta tag https://adityatelange.github.io/hugo-PaperMod/

image

Cephra commented 5 months ago

@adityatelange I've looked into the issue a bit more. It seems that the reason why the menu is rendering in the example site is this:

languages:
  en:
# ...
    menu:
      main:
        - name: Archive
          url: archives
          weight: 5
        - name: Search
          url: search/
          weight: 10
        - name: Tags
          url: tags/
          weight: 10
        - name: WiKi
          url: https://github.com/adityatelange/hugo-PaperMod/wiki/

I didn't put any translations in my toml and thus I'm relying on hugos internal menu generation.

Once I remove those translations in the exampleSite, I can reproduce the issue.

Now I wonder, is this actually an issue and if so, is it related to hugo or paperMod?

Maybe you can help!

Thanks,

Chris

Cephra commented 5 months ago

Ah, I seem to have been wrong about how menus work in hugo. I've figured it out now!

If anyone else comes across this, it seems that it was working before because of a bug in hugo which was fixed in https://github.com/gohugoio/hugo/pull/12349/files & https://github.com/gohugoio/hugo/pull/12403/files

Cheers!

ashishb commented 1 month ago

@Cephra I am facing the same issue. What's the underlying cause and the fix?

Cephra commented 1 month ago

@Cephra I am facing the same issue. What's the underlying cause and the fix?

I've set menus = "main" in the front matter and it works

ashishb commented 1 month ago

I've set menus = "main" in the front matter and it works

In which file - hugo.yaml?

Cephra commented 1 month ago

I've set menus = "main" in the front matter and it works

In which file - hugo.yaml?

I use TOML in my project but in YAML it should be:

---
# ...your front matter stuff...
menus: main
---
Cephra commented 1 month ago

As an alternative you could create a folder and put an _index.md file in it with the content you want to have. That way, since it's in a folder, it'll create a menu entry for it. However I preferred to do it with setting menus prop to main.

ashishb commented 1 month ago

Thanks.

However I preferred to do it with setting menus prop to main.

Can you elaborate on what this means?

Cephra commented 1 month ago

Thanks.

However I preferred to do it with setting menus prop to main.

Can you elaborate on what this means?

Can you just give me the .md file that isn't showing up in the menu? I will fix it for you.

ashishb commented 6 days ago

This is one of those that fail with

2.539 ERROR render of "term" failed: "/code/website/themes/PaperMod/layouts/_default/baseof.html:20:8": execute of template failed: template: _default/list.html:20:8: executing "_default/list.html" at <partialCached "header.html" . .Page>: error calling partialCached: "/code/website/themes/PaperMod/layouts/partials/header.html:127:38": execute of template failed: template: partials/header.html:127:38: executing "partials/header.html" at <site.GetPage>: error calling GetPage: page reference "Tech thoughts" is ambiguous
---
author: [admin]
date: "2015-02-01T21:30:15+00:00"
guid: http://ashishb.net/?page_id=2290
title: Tech thoughts
url: /tech-thoughts/

---
{{< catlist category="tech-thoughts" catlink=yes count=100 >}}