如何在雨果中为每种内容类型添加菜单

时间:2019-03-03 16:39:58

标签: blogs hugo static-site

我的hugo网站具有以下目录结构:

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

我希望该站点的main菜单包含poststalks的条目。目前,我可以通过在前面添加about来为menus = main添加菜单项,但是,我希望poststalks链接重定向到索引内容,而不是我直接维护的静态页面。这可能吗?

1 个答案:

答案 0 :(得分:0)

事实证明,使用menu中的config.toml配置可以做到这一点。 weight属性用于订购菜单:

[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