Menus not populated

Hi all,
first of all, thanks for Hugo!
I have a problem with my menus: they are not populated.
I put in my config.toml:

sectionPagesMenu = "main"

My website has a lot of sections, I can see them with:

 {{ range .Site.Sections }}
    <li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
    {{ range .Sections }}
       <li class="active">
          <a href="{{ .URL }}">{{ .Name }}</a>
    {{ end }}
{{ end }}

Yelds all the subsections:

WAZIUP Tutorials
LoRa sensing and gateway
Build IoT apps with Waziup
How Waziup works?
API Reference
Waziup platform User Guide
Why use WAZIUP? 

But using menus doesn’t work.

{{ $currentPage := . }}
{{ range .Site.Menus.main }}
     {{ if .HasChildren }}
         <li class="{{ if $currentPage.HasMenuCurrent "main" . }}active{{ end }}">
            <a href="#">
                {{ .Pre }}
                <span>{{ .Name }}</span>
         <ul class="sub-menu">
           {{ range .Children }}
              <li class="{{ if $currentPage.IsMenuCurrent "main" . }}active{{ end }}">
                  <a href="{{ .URL }}">{{ .Name }}</a>
           {{ end }}
     {{ else }}
              <a href="{{ .URL }}">
                 {{ .Pre }}
                 <span>{{ .Name }}</span>
     {{ end }}
{{ end }}

Yelds only 3 (unrelated) subsections:

LoRa sensing and gateway

The source of the website is here:

It works with front matters:

      title: foo
      parent: bar
      weight: 4

But using the “Section Menu for Lazy Bloggers” method doesn’t work.
Probably because my pages are nested (sections inside sections inside sections).

I am having the same problem with my new site

source for site

source for theme


I find that the HTML for the pages is being generated but the HTML for /blog/index.html has errors.

I had created 3 posts in /blog/ but this page just has three empty <span>

  <div id="mobile-navbar" class="mobile-navbar">
  <div class="mobile-header-logo">
    <a href="/" class="logo"></a>
  <div class="mobile-navbar-icon">
<nav id="mobile-menu" class="mobile-menu slideout-menu">
  <ul class="mobile-menu-list">
    <a href="/">
        <li class="mobile-menu-item">Home</li>
      </a><a href="/blog/">
        <li class="mobile-menu-item">Blog</li>
      </a><a href="/categories/">
        <li class="mobile-menu-item">Categories</li>
      </a><a href="/events/">
        <li class="mobile-menu-item">Events</li>
      </a><a href="/tags/">
        <li class="mobile-menu-item">Tags</li>
      </a><a href="/help/">
        <li class="mobile-menu-item">Help</li>

@comaldave from your website, which template/partial is used to generate the HTML you gave?

I don’t know! I think I know but I am new at this.

First I checked what the browser received.


The project is organized into a primary repo with submodules for:
  • public so that site can be served from root of master
  • content so that I can authorize family members to use GitHub to add posts.
  • each of the themes in the themes directory, one of which is the one I am creating.

The file being served may have been changed by JS on the browser but I still see the same errors.

I am thinking that the file was generated using the contents of /layout/ but layouts is an empty folder.

This means that it must be coming from the selected theme.

This is a fork of another theme which seemed to be working. I have not made many changes yet.

partials/blog is a copy of partials/post

Thank you for looking at this for me. I have started a new bare site and am going through the tutorial again, hoping I make fewer mistakes.

Problem Solved for me

my son also uses Hugo. He replaced my theme with his theme and every thing works. He also tested it with a theme by spf13 and it worked fine. He suggested that I use a theme that works, and if I want to create my own theme:

Use something from spf13 as your baseline for being able to say “I know it works with hugo’s author’s own theme, so this issue must be with this theme”.
Sorry this does not solve your problem but it may give you an idea of how to identify it.

1 Like

OK, great to hear.
I suggest that you import your style elements one by one into your working base theme.