How can i create another menu in my content folder in a .md file using HUGO?

huangapple go评论90阅读模式
英文:

How can i create another menu in my content folder in a .md file using HUGO?

问题

我正在尝试在另一个页面上创建一个与我的主菜单不同的菜单,我在config.toml文件中编写了代码,但我不知道如何将其放入我的.md文件中。以下是config.toml文件中的代码:

[menu]

# 主菜单

[[menu.main]]
name = "Inicio"
identifier = "menu.Inicio"
url = "/"
weight = 1

[[menu.main]]
name = "Nosotros"
url = "/about-us"
weight = 2
parent = "menu.Inicio"

以下是我在.md文件中的代码示例:

[![enter image description here][1]][1]

[1]: https://i.stack.imgur.com/F00Ky.png

希望这可以帮助到你!

英文:

I trying to create a different menu than my main menu on another page, i write my code in the config.toml but i have no idea how can i put in my .md files.there is my code in the config.toml file

    [menu]

#Main Menu

[[menu.main]]
name        = "Inicio"
identifier  = "menu.Inicio"
url         = "/"
weight      = 1
[[menu.main]]
name        = "Nosotros"
url         = "/about-us"
weight      = 2
parent      = "menu.Inicio

and there is my code in my .md file for example

答案1

得分: 1

选项一:

在您网站的config.toml文件中,您可以声明多个菜单。Hugo不要求这样做,但将它们列在一个地方会很有帮助:

menu = ['main', 'pasto']

然后在内容页面中,您可以将该内容项分配给一个或多个菜单。例如,在前置元数据中的content/posts/first-page.md文件中:

...
menu:
  main:
    title: "First page"
    weight: 1
---

对于多个菜单,添加另一个菜单条目:

...
menu:
  products:
    title: "Second product"
    weight: 2
  main:
    title: "See our Second product"
    weight: 3
---

选项二:

不要在内容文件中创建菜单条目。相反,您可以在网站的config.toml文件中添加菜单或菜单的链接。

[menu]
[[menu.main]]
  identifier = "pageOne"
  name = "First page"
  weight = 1
  url = "/posts/first-page"
[[menu.main]]
  identifier = "productOne"
  name = "Please view Product one"
  weight = 2
  url = "/posts/product-one"
[[menu.products]]
  identifier = "productsProductOne"
  name = "Product one"
  weight = 1
  url = "/posts/product-one"
英文:

Option one:

In your site's config.toml file, you can declare multiple menus. Hugo doesn't require this, but it's helpful to list them in one place:

menu = ['main', 'pasto']

Then in the content pages you can assign that content item to one or multiple menus. In the frontmatter, for example content/posts/first-page.md:

...
menu:
  main:
    title: "First page"
    weight: 1
---

For multiple menus, add another menu entry:

...
menu:
  products:
    title: "Second product"
    weight: 2
  main:
    title: "See our Second product"
    weight: 3
---

Option two:

Do not create menu entries in the content files. Instead, you can add links to the menu or menus in the site's config.toml file.

[menu]
[[menu.main]]
  identifier = "pageOne"
  name = "First page"
  weight = 1
  url = "/posts/first-page"
[[menu.main]]
  identifier = "productOne"
  name = "Please view Product one"
  weight = 2
  url = "/posts/product-one"
[[menu.products]]
  identifier = "productsProductOne"
  name = "Product one"
  weight = 1
  url = "/posts/product-one"

huangapple
  • 本文由 发表于 2022年6月14日 14:17:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/72612284.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定