Hi Hugo community,
I’ve been re-building my portfolio site: https://www.santoroland.com/
Amongst many changes I wanted to update the menu system from the lazy blogger menu which required me to add the years into the site config:
Menu Templates | Hugo
To the ‘more advanced’ one which in theory would only require menus to be defined in the posts front matter:
Menu Templates | Hugo
The issue I am getting is that the menu is rendering inconstantly on the dev server:
As you can see, years and posts get repeated. This happens most of the time when after the dev server builds the site…and then changes randomly sometimes on content updates or site refreshes.
Here is an example front matter
title: "Bladerunner 2049"
draft: false
date: 2017-12-29T14:49:13-04:00
showonlyimage: false
image: "img/work/bladerunner2049/bladerunner2049_header.jpg"
tags: ["VFX","film",'bladerunner2049','bladerunner','nuke','compositing']
summary: "Breakdown of sequences lead for the 2017 film Bladerunner 2049."
menu:
work:
parent: '2017'
weight: 20171225
name: "Bladerunner 2049"
And then the code used to read the site menu into the sidebar:
<!-- work menu start-->
<ul>
{{ $currentPage := . }}
{{ range .Site.Menus.work.Sort.Reverse }}
{{ if .HasChildren }}
<li>
<a class="s-sidebar-nav-link" href="">
{{ .Name }}
</a>
<ul>
{{ range .Children }}
<li {{if $currentPage.IsMenuCurrent "main" . }} class="active"{{end}}>
<a class="s-sidebar-nav-link" href="{{.URL}}">{{ .Weight }} - {{ .Title }}</a>
</li>
{{ end }}
</ul>
{{ end }}
{{end}}
</ul>
Here is a link to the git repo.
https://github.com/santororock/santoroland.com
One more thing to note, is that while the hugo dev server is running, if I re-save any of the content.md files, the menu will often begin rendering correctly once more.
Isn’t that weird?!
Am I missing something super obvious?
Thanks!
-Luigi