Specifying nested menus in config.toml

In my menu I have these entries:

[[menu.main]]
    identifier = "about"
    name = "About"
    url = "/about/"
    weight = 300

  [[menu.about]]
    identifier = "expertise"
    name = "Capabilities"
    url = "/about/capabilites/"
    parent = "about"
    weight = 310

  [[menu.about]]
    identifier = "education"
    name = "Education"
    url = "/about/education/"
    parent = "about"
    weight = 320

  [[menu.about]]
    identifier = "projects"
    name = "Experience"
    url = "/about/experience/"
    parent = "about"
    weight = 330

There are no submenus on the main menu item ‘About’ and each nested menu’s *.md file displays as a single paragraph rather than with the H1 heading and a following list. The contents also appear on other pages.

What have I done incorrectly?

Rich

[[menu.main]]
name = "About"
pageRef = "/about"
weight = 1

[[menu.main]]
name = "Capabilities"
pageRef = "/about/capabilities"
parent = "About"
weight = 1

[[menu.main]]
name = "Education"
pageRef = "/about/education"
parent = "About"
weight = 2

[[menu.main]]
name = "Experience"
pageRef = "/about/experience"
parent = "About"
weight = 3

All entries are part of one menu… main.
You can omit the identifier key if there are no duplicate name entries.
Use pageRef for internal links, and url for external links.

This assumes the following structure:

content/
├── about/
│   ├── capabilities.md
│   ├── education.md
│   ├── experience.md
│   └── _index.md
└── _index.md

Joe,

Thank you. I never picked that up when reading the Hugo web pages on menus
or on other pages about nested menus.

Making these changes the main menu now has (among others) About and
about(v). The first has the _index.md displayed but no nested menus; the
latter has only the nested menu names, no content in any of them. And, the
contents of all three nested menus (as single paragraphs each) are appended
to the Home page and a couple of others. Trying to access the various menu
options either doesn’t work or shows a different page.

I’ll continue playing with this. I won’t post the entire site on git hub,
it’s for my business.

Regards,

Rich

I don’t understand what any of this means.

Then I think you are on your own at this point.

I don’t understand what any of this means.

Joe,

I hope this clarifies my situation:

All entries are part of one menu… main.
You can omit the identifier key if there are no duplicate name entries.
Use pageRef for internal links, and url for external links.

I did these changes (and removed the terminal ‘/’ on the pageRefs, but there
are still issues needing resolution and my web searches haven’t found the
fixes.

Here’s my menu tree:

>-Home
>  +-_index.md
> 
+-Kudos
>  +-testimonials.md
>
+-About
>  +-_index.md
>  >
>  +-Capabilities
>  >    +-_index.md
>  +-Education
>  >    +-_index.md
>  >-Experience
>       +-_index.md
>
+-Library
>  +-_index.md
>  >
>  +-topic-1
>  >    +-topic-1.md
>  +-topic-2
...
>-Blog
>  +-_index.md (empty)
>  >
>  +-post-1.md
>
+-Contact
>  +-contact.md
  1. The Home page displays the _index.md contents followed by part of the
    library’s _index.md and all the nested subdirectories with a paragraph of all
    document titles.

  2. The Kudos page displays correctly.

  3. The About page does not display _index.md. When I click on this menu item
    nothing happens, but when I click on the down arrow adjacent to the menu item
    the nested menus display. Clicking on a nested menu displays its contents
    followed by the Library/_index.md and all its subdirectories.

  4. The Library page does not display _index.md. The subdirectories display as
    nested menus but the *.md each contains produces a 404 page when I click on
    that nested menu item. (I didn’t move each *.md to _index.md in the Library
    directory.)

  5. The Blog page does not display post-1.md, only the Library’s _index.md and
    all submenu contents as single paragraphs rather than as lists with links to
    the static directory.

  6. The contact page displays correctly.

There’s currently no style.css for the tikva theme or in /static/.

I’d appreciate a pointer to a Hugo page that teaches me what I’ve done
incorrectly in creating all markdown contents and in the config.toml menu
section.

Regards,

Rich

This is impossible to troubleshoot without access to your project’s source.

Joe,

I’m making a copy that I’ll post to github today.

Rich

Joe,

I’ve not before uploaded any code to github so if there’s an issue with
getting the site downloaded let me know and I’ll find how to fix the
problem.

The reponsitory URL is https://github.com/rs-aesi/company-web-site.

Rich

The repo is empty.

Well, that’s not good. I wonder why. I thought I copied the local site there
so I will find out why it didn’t work.

Thanks, Fredrick,

Rich

Github tells me that my authentication was withdrawn last year. I’ve not
found how I use the command line to re-authenticate so I can push the local
site to its github repo.

All suggestions appreciated,

Rich

There are now files present.

Rich

Ugh.

1) Several of your menu entries in config.toml specify url rather than pageRef. That is why some of your menu items don’t get the active class when visited.

2) None of your content files have any front matter. Typically you want to have at least title and date. That way you can rely on templates’ use of {{ .Title }} in head, body, and meta elements. Then you can remove the level 1 headings from the content of your markdown.

3) Get used to using ATX headings instead of Setext headings. It makes content creation/editing a bit easier.

4) Your archetypes directory is a bit of a mess:

    archetypes/
    ├── about.md
    ├── about.md~
    ├── default.md    <-- keep this, delete the others
    ├── library.md
    └── library.md~

5) You can delete the config directory and its contents. It is useless because you already have config.toml in the root of your project.

6) You can delete the ebug directory and its contents.

7) I’m not sure why you are using _index.md files (branch bundles) for many of your pages instead of index.md files (leaf bundles) or even regular pages (e.g., 'content/about/education.md`). I would expect a structure like this instead.

structure
content/
├── about/
│   ├── capabilities.md
│   ├── education.md
│   ├── experience.md
│   └── _index.md
├── blog/
│   ├── _index.md
│   └── post-1.md
├── library/
│   ├── _index.md
│   ├── subject-1.md
│   ├── subject-2.md
│   └── subject-3.md
├── section/
│   ├── footer/
│   │   ├── column1.md
│   │   ├── column2.html
│   │   ├── column3.md
│   │   └── index.md
│   └── subfooter/
│       ├── copyright.html
│       └── index.md
├── contact.md
├── _index.md
└── testimonials.md

8) It’s not clear why you copied all of the theme files into the layouts directory in the root of your project. Only copy those files that you wish to override.

9) The Tikva theme is minimally maintained. In my view that’s a bit of a red flag.

10) Your issue with not having a clickable link for menu items with children is caused by the Bootstrap dropdown implementation[1]. The relevant code is here. You’ll need to raise an issue (a) with the theme author, or (b) on another forum (e.g., Stack Overflow). Note that the Tikva theme is using an older version of Bootstrap (v4.4.1).

11) Your issue with the wrong content being listed in certain places is due to a single list template that iterates over .Site.Params.mainSections. You’ll need to either (a) create list templates specific to the relevant sections, or (b) override the the existing list template, iterating over .Pages instead of .Site.Params.mainSections.


  1. This is not a trivial problem to solve. This jQuery example seems to work… sort of. javascript - Bootstrap 4 - Keeping Parent of Dropdown a clickable link - Stack Overflow ↩︎

I’m not allowed to make more than 2 responses to the thread I started so I posted my response here: https://tinyurl.com/2p92wwx2.

I’ll look for a new theme and start over using a better supported one.

Thanks again all,

Rich

I’ve updated your Trust Level, so you should be able to respond freely. You may have to logout/login for the change to take effect.

Thank you, Joe.

I’ve downloaded the ‘justice’ theme and need to closely examine it to figure
out how to use it for my needs.

Rich

1 Like