Rich Ashworth
Rich Ashworth

Reputation: 2015

How can I add a menu for each content type in hugo

I have the following directory structure for my hugo site:

content/
   - posts/
      - some_post.md
   - talks
      - some_talk.md
   about.md

I would like the main menu for this site to include entries for posts and talks. Currently I am able to add a menu item for about, by adding menus = main to the front matter, however, I would like the posts and talks links to redirect to indexes of their content, rather than be static pages that I maintain directly. Is this possible?

Upvotes: 1

Views: 1088

Answers (1)

Rich Ashworth
Rich Ashworth

Reputation: 2015

It turns out that this is possible using the menu configuration in config.toml. The weight attribute is used for ordering the menus:

[menu]

  [[menu.main]]
    identifier = "home"
    name = "home"
    url = "/"
    weight = 10

  [[menu.main]]
    identifier = "blog"
    name = "blog"
    url = "/post/"
    weight = 20

  [[menu.main]]
    identifier = "talks"
    name = "talks"
    url = "/talks/"
    weight = 30

  [[menu.main]]
    identifier = "about me"
    name = "about me"
    url = "/about/"
    weight = 40


Upvotes: 3

Related Questions