hugo-theme-docdock icon indicating copy to clipboard operation
hugo-theme-docdock copied to clipboard

Feature request: Add theme setting for default sorting of menu entries

Open siamkreative opened this issue 7 years ago • 7 comments

Hi @vjeantet

With the recent content organization, my navigation entries don't seem to be sorted alphabetically like it used to be. I do no specify the weight attribute.

I am using Hugo version 0.25 and your theme at commit 5869299972c981931908be24b0f378039197e2d4. My entries used to be sorted alphabetically but now it looks like it's sorted by date.

If no weights are provided (or if weights are the same), date will be used to sort https://gohugo.io/content/ordering/

Cheers

siamkreative avatar Jul 10 '17 03:07 siamkreative

Update

I just found a way to do it by changing {{ range $pages.ByWeight }} to {{ range $pages.ByTitle }} in layouts/partials/menu.html.

Is there a better way to do this without having to override the whole template? Can I somehow specify it in the config file?

siamkreative avatar Jul 10 '17 04:07 siamkreative

@vjeantet I hope you don't mind me following up on this. Do you have any idea why me menu entries are not sorted alphabetically by default?

siamkreative avatar Jul 17 '17 06:07 siamkreative

Hello @SiamKreative I order menu entries by weight.

I will add an option into site conf to allow you to choose ordering type.

vjeantet avatar Jul 19 '17 06:07 vjeantet

Thanks! Can't wait :)

siamkreative avatar Jul 19 '17 08:07 siamkreative

add ordersectionsby = "title" in your config.toml

vjeantet avatar Jul 19 '17 21:07 vjeantet

Thanks for this! It does not seem to affect top level entries. I will fix that by setting weight on them.

siamkreative avatar Jul 20 '17 01:07 siamkreative

I might have been slightly unclear about the expected result. Right now, it is impossible to overrides the default sorting (ordersectionsby) using the weight attribute. I believe we should still be able to overrides the menu entries sorting by weight.

siamkreative avatar Jul 27 '17 04:07 siamkreative