Possible to add taxonomies in auto-generated menu?


I was wondering if it’s possible to insert include the taxonomies in the auto generated menu? While I am aware I can do it like the following…:

{{- range $name, $taxonomy := .Site.Taxonomies.tags -}}
  <!-- HTML code -->
{{- end -}}

…I am specifically looking at how to insert this at a specific position in my current menu.

Currently, I have my menu something like this…:

which is generated using the following:

{{- $currentPage := . -}}
  {{- range .Site.Menus.main -}}
    {{- if .HasChildren -}}
      <!-- HTML code -->
    {{- else -}}
      <!-- HTML code -->
    {{- end -}}
  {{- end -}}
<!-- If I add the above code here, it goes at the end of the menu, that is after the contact page which is undesirable -->

And I have set the order of menu items using their frontmatter, for example, this is from the content/projects/_index.md:

title: "Projects"
    pre: "thumbnails"
    weight: 4

So, from what I have read and understood about Hugo Menus till now, it seems that it’s not possible. Is that so?

You can add metadata to taxonomies and terms: https://gohugo.io/content-management/taxonomies#add-custom-metadata-to-a-taxonomy-or-term

1 Like

Yes, that does help. Thanks a lot! I thought there was some way to do it automatically because I was planning to make this as a theme. So I thought it would be great if users didn’t have to configure it themselves.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.