Error when trying to sort

I am trying to print out all page titles in sorted order. Based on the documentation for sort, am using the following code:

    {{ range sort .Site.Pages "Title" }}

{{ .Title }}

{{ end }}

However, this produced the following error:

ERROR: 2015/07/01 Error while rendering homepage: reflect: call of reflect.Value.FieldByName on ptr Value

I assume that I am doing something wrong, but have no idea what. Any help would be much appreciated.

Thank you!

Same thing happened here!

Tried to sort based on params ended up like that too

{{ range sort .Site.Pages "Params.normalizedtitle" }}
<p>{{ .Params.normalizedtitle }}</p>
{{ end }}

but the where works fine

where .Data.Pages "Params.language" "Indonesia"

Anyone can help on this please :slight_smile:

There are builtin functions to sort pages:


{{ range sort .Site.Pages "Title" }}

Would be:

{{ range .Site.Pages.ByTitle }}

The sort func is, reading the doc, primary meant for “other lists”, but I guess should also work for pages. @DerekPerkins would know.

There seems to be a lot of bugs like this in Hugo. Another problem I ran into is functions returning weighted pages, when there is no discussion of what weighted pages are in the docs. Yet another problem is that accessing .Reverse reverses the actual list instead of returning a reversed copy of the original. The only way I could figure out what Hugo was doing was by reading the source.

The simplest solution was to stop using Hugo. Jekyll may be a lot slower, but it does what it says it does!

It you have concrete bugs, opening up a GitHub issue would be more fruitful. .Reverse on Pages operates now on a (cached) copy (in 0.15-DEV).

Hugo is a open source project contributed to 100% by volunteers in their free time. While it’s not by any means perfect, the docs are pretty comprehensive and the code is generally stable. The docs do indeed talk about pages weight. . We even had one user running Hugo on over 500k content files successfully without any issues.

As Hugo is a volunteer effort, it depends on people like you to make it better. One of the best ways to contribute is to report bugs so we can fix them. You’ll find that we’re actually quite good at fixing them quickly. Another way to help is to add documentation or even just file tickets about missing parts of the documentation.

We’re sorry to see you go. Jekyll is a good project with a good community around it and a solid option, but to think it’s without bugs is just a very naive and incorrect statement. Jekyll has plenty of bugs . They are in the middle of a major rewrite to address some of the limitations of the current architecture.


I switched from docpad to Jekyll and find it not satisfactory, and now to hugo and staying. I like hugo’s overall approach better… and speed :grin:

I’m hoping that too as stated in

Sorts maps, arrays and slices, returning a sorted slice. A sorted array of map values will be returned, with the keys eliminated. There are two optional arguments, which are sortByField and sortAsc. If left blank, sort will sort by keys (for maps) in ascending order.

Works on lists, taxonomies, terms, groups

Yes, it should work with page lists - if it doesn’t please open up a GitHub issue.

as instructed

Say no more:

1 Like

you guys rock!