Is there a way of setting a default weight for menu items added via sectionPagesMenu
I’ve yet to find one and my section pages seem to always be added on last.
The default is 0. So you might use -1 and 1 to sort pages before and after unsorted pages.
Other than that there are plenty of filters when you range through pages where you can order by title, date, etc.
Doesn’t seem to work
sectionPagesMenu = "main"
---
title: Contact
menu:
main:
weight: 100
---
and contact is still at the front
No.
Specifying a weight for the Contact page will not change its menu position relative to the sections added by sectionPagesMenu = "main"
because items with no weight or zero weight are both considered to have their weights undefined, and they will sort to the bottom. This applies to weights on pages as well.
So if I have these menu items:
Name | Weight |
---|---|
A | 10 |
B | 0 |
C | |
D | -10 |
The sorted list will be:
D
A
B
C
Instead of using the sectionPagesMenu
setting, explicitly define the menu items in your site configuration. This will give you more control.
So the easiest (and perhaps only-est) method is to create an _index.md for each section with
menu:
main:
weight: 1
in it?
I think the easiest method is to define your menus in site configuration.
[[menu.main]]
name = "Contact"
url = "/contact/"
weight = 2
[[menu.main]]
name = "Posts"
url = "/Posts/"
weight = 1
[[menu.main]]
name="Articles"
url = "/Articles/"
weight = 3