# sectionPagesMenu default weight

**URL:** <https://discourse.gohugo.io/t/sectionpagesmenu-default-weight/33164>\
**Category:** support\
**Created:** [May 31, 2021, 3:57am UTC](https://discourse.gohugo.io/t/sectionpagesmenu-default-weight/33164 "2021-05-31T03:57:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DoctorOW](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/doctorow/32/7977_2.png) [@DoctorOW](https://discourse.gohugo.io/u/DoctorOW)\
**Post date:** [May 31, 2021, 3:57am UTC](https://discourse.gohugo.io/t/sectionpagesmenu-default-weight/33164/1 "2021-05-31T03:57:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [May 31, 2021, 10:32am UTC](https://discourse.gohugo.io/t/sectionpagesmenu-default-weight/33164/2 "2021-05-31T10:32:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DoctorOW](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/doctorow/32/7977_2.png) [@DoctorOW](https://discourse.gohugo.io/u/DoctorOW)\
**Post date:** [May 31, 2021, 4:37pm UTC](https://discourse.gohugo.io/t/sectionpagesmenu-default-weight/33164/3 "2021-05-31T16:37:38Z")

</div>

Doesn’t seem to work  
`sectionPagesMenu = "main"`

```auto
---
title: Contact
menu: 
    main:
        weight: 100
---

```

and contact is still at the front

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [May 31, 2021, 5:55pm UTC](https://discourse.gohugo.io/t/sectionpagesmenu-default-weight/33164/4 "2021-05-31T17:55:12Z")

</div>

> [@DoctorOW](#):
>
> Is there a way of setting a default weight for menu items added via `sectionPagesMenu`

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.

---

<div class="post-metadata">

**Author:** ![DoctorOW](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/doctorow/32/7977_2.png) [@DoctorOW](https://discourse.gohugo.io/u/DoctorOW)\
**Post date:** [May 31, 2021, 6:22pm UTC](https://discourse.gohugo.io/t/sectionpagesmenu-default-weight/33164/5 "2021-05-31T18:22:33Z")

</div>

So the easiest (and perhaps only-est) method is to create an \_index.md for each section with

```auto
menu: 
    main:
        weight: 1

```

in it?

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [May 31, 2021, 6:27pm UTC](https://discourse.gohugo.io/t/sectionpagesmenu-default-weight/33164/6 "2021-05-31T18:27:08Z")

</div>

I think the easiest method is to define your menus in site configuration.

```auto
[[menu.main]]
name = "Contact"
url = "/contact/"
weight = 2

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

[[menu.main]]
name="Articles"
url = "/Articles/"
weight = 3

```
