I’m trying to set up a menu using Hugo’s Menu Documentation, but I’m encountering a syntax and interface error. Here’s what I’ve tried:
Front Matter Example (as per Hugo documentation)
Based on the documentation, I tried using the following front matter for my “Terms of Business” page:
---
title: Terms of Business
menus:
footer:
- params:
addendum: true
parent: Consulting Services
---
Error Encountered
However, when I use this configuration, I get the following error:
unable to process menus for page "/company/terms-of-business": unable to cast []interface {}{map[string]interface {}{"params":map[string]interface {}{"adendum":true}, "parent":"Consulting Services"}} of type []interface {} to map[string]interface{} logged 1 error(s)
Alternative Attempt (Without List Structure)
To troubleshoot, I tried removing the list structure and used the following:
---
title: Terms of Business
description: Terms of Business for the services provided by the company.
menus:
footer:
params:
adendum: true
parent: Consulting Services
---
Current Data Output
With this change, my data outputs as follows:
{{ Consulting Services Terms of Business 0 Terms of Business map[adendum:true]} footer Page(/company/terms-of-business) []}
Problem: I’m unable to access adendum
within my menu template.
Template Code Snippet
Here’s the template code I’m using to render the menu items:
<!-- -->
{{- range .Site.Menus.footer }}
<div class="col-sm-12 col-md-6 col-lg-4 col-xl-4 col-xxl-2">
<h4 class="p-2 text-white">{{ .Name }}</h4>
<hr />
<ul class="navbar-nav justify-content-end flex-grow-1 pe-3">
{{- range .Children }}
{{ . }}
{{- with .Page }}
<li class="nav-item">
<a class="nav-link p-0" href="{{ .Permalink }}" title="{{ .Params.card.title }} - {{ .Params.card.content | plainify }}">
<small><i class="fa-light fa-chevron-right pe-1"></i>{{- if .Params.shorttitle }}{{- .Params.shorttitle }}{{- else }}{{- .Title }}{{- end }}</small>
</a>
</li>
{{- end }}
{{- end }}
</ul>
</div>
{{- end }}
<!-- -->
Request for Assistance
How can I correctly configure the menu in the front matter so that I can access the adendum
parameter within my template? Any insights into what I might be doing wrong or alternative approaches would be greatly appreciated.