英文:
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
答案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"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论