Builds crash under some conditions related to menus

Hello!
My Hugo builds crash dramatically under some conditions related to menus. I would like to know if that’s reproducable for others or just expected behavior because I made something wrong or because my environment is too weak.

[
  {
    "ConfiguredURL": "/about/",
    "Page": null,
    "PageRef": "",
    "Name": "about hugo",
    "Menu": "main",
    "Identifier": "about",
    "Pre": "\u003ci class='fa fa-heart'\u003e\u003c/i\u003e",
    "Post": "",
    "Weight": -110,
    "Parent": "",
    "Children": null,
    "Params": null
  },
  {
    "ConfiguredURL": "/getting-started/",
    "Page": null,
    "PageRef": "",
    "Name": "getting started",
    "Menu": "main",
    "Identifier": "",
    "Pre": "\u003ci class='fa fa-road'\u003e\u003c/i\u003e",
    "Post": "\u003cspan class='alert'\u003eNew!\u003c/span\u003e",
    "Weight": -100,
    "Parent": "",
    "Children": null,
    "Params": null
  }
]

Now comes the weird part:

  • I added an additional frontmatter menu: main in file content/menutest.md.
  • Started hugo or hugo server (with some flags or without).
  • After a console message
Start building sites …
hugo v0.97.3+extended linux/amd64 BuildDate=unknown
WARN 2022/04/28 23:01:13 .Path when the page is backed by a file is deprecated and will be removed in a future release. We plan to use Path for a canonical source path and you probably want to check the source is a file. To get the current behaviour, you can use a construct similar to the one below:

{{ $path := "" }}
{{ with .File }}
{{ $path = .Path }}
{{ else }}
{{ $path = .Path }}
{{ end }}

Re-run Hugo with the flag --panicOnWarning to get a better error message.

the process crashes with many error messages. I can only provide the last 300 lines because the buffer of my console is too small for all: menu-test/error.txt at main · GHSVS-de/menu-test · GitHub

  • I understand that it has something to do with the Page that I’ve added to the menu but why :wink:
  • When I output the menu with range all three items are present.

Thank you!

The jsonify function doesn’t work with all data structures. In this case, the addition of menu entry via front matter causes the failure. Hugo shouldn’t panic, but using jsonify for debugging isn’t a documented feature either. You’re welcome to create an issue if you feel strongly about it.

Do this instead:

<pre>{{ debug.Dump site.Menus.main }}</pre>

Thank you. I will create an issue on GitHub in the next few days.

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