如何使用Hugo在.md文件中的内容文件夹中创建另一个菜单?

发布于 2025-02-07 03:28:39 字数 563 浏览 1 评论 0原文

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

    [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

,我的.md文件中有我的代码

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

在你怀里撒娇 2025-02-14 03:28:39

选项一:

在您的网站的config.toml文件中,您可以声明多个菜单。 不需要

这个

雨果 菜单。在FrontMatter中,例如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"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文