Sadly Not Surprised

The tragic crime playing out in Lewiston Maine makes me sad but I’m not at all surprised. Maine, like nearly all the States in the USA has gun laws far more lax than required by the 2nd Amendment. So they have far more gun deaths than Massachusetts by nearly a factor of four! Maine ranks 17th of 50 while Massachusetts ranks #1 for gun safety.

Since Maine was originally part Massachusetts, and it’s population in the southern region is increasingly migrants from states in the top 5 for gun safety, I hope they will wake up and adopt some the successful gun safety laws that Massachusetts has had for decades.

Sadly, this is likely to be the common response from the gun nuts.

Hugo Menus Sort Order

I’ve been working on porting my ancient main website to Hugo on and off for almost a year. The reason my site hasn’t had a major update in over 20 years is the difficulty in creating site menus.

The original site was designed with a full custom theme in FrontPage with its great drag and drop GUI menu builder. In 20 years I have never found any other tool that makes menu creation so easy. I’d heard the very expensive Macromedia (now Adobe) Dreamweaver has something but I’ve never been able to try it out, and frankly won’t spend that kind of money on a personal website.

Every year I’d search for something with an easy to use menu builder but I’ve never found anything. So I finally gave up and settled for the Hugo static site builder system. It sucks having to create the menu system in plain text but I had to give in.

One thing that has bugged me is that nowhere could I find a definitive explanation of how the menu system sorts entries. Today I persisted in searching and was able to piece together an answer and come up with a methodology that works for me.

Here’s a list of the important points

  • Order within the menu configuration text is ignored because Hugo menus can be defined in front matter or in two different ways in the site configuration. This makes it difficult to near impossible to allow a code position sort order.
  • The default sort is ascending by weight then alphabetical by name within a menu level

Most of the time I want my menus sorted by name with only one item forced to a specific position, so I’ve come up with this strategy.

  • Manually sort the parent and child menu entries in the order you want them to display as a visual reference.
  • Assign a weight to each top level (parent) item starting with 10 and incrementing by 10 for each parent level
  • Assign the same weight as the parent to each sub level (child) item
  • When rendered, if the order is different compared to the desired order, adjust the weight of the menu items to compensate.