New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ByLinkTitle seemingly sorts by date if link title not explicitly set #4953

zombiezen opened this Issue Jul 16, 2018 · 3 comments


None yet
2 participants

zombiezen commented Jul 16, 2018

I have a bunch of content in my Hugo site that I'm sorting by link title in a list template (using .Data.Pages.ByLinkTitle). However, .ByLinkTitle appears to not work as documented; it appears to be sorting by date order. .ByTitle works as expected. All of the content being sorted does not have an explicit link title set, but they do all have titles set in the front matter. I'm able to reproduce this on Hugo 0.44.

The site source is here, you can reproduce by changing this line of layouts/commands/list.html to use .ByLinkTitle and seeing the effects on /cmd/. Let me know if you need a more minimal reproduction case.

Based on examining the Hugo source briefly, what I'm suspecting here is that Page.linkTitle is not being set correctly to the implicit default of title when considering for sort, but I couldn't confirm this with certainty.


This comment has been minimized.


bep commented Jul 16, 2018

I just checked the code, and it sorts by linkTitle only -- which I think is wrong, but not in the way you describe.

I would expect it to sort by LinktTitle (the method), which has a fallback to title if no linkTitle etc. Now you will get odd results for the pages where no value is set for that field in front matter. We should probably also do the same the other way around for ByTitle.


This comment has been minimized.

stale bot commented Nov 13, 2018

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

@stale stale bot added the Stale label Nov 13, 2018


This comment has been minimized.

zombiezen commented Nov 13, 2018

I don't believe this bug has been fixed.

@stale stale bot removed the Stale label Nov 13, 2018

@bep bep added the Bug label Nov 13, 2018

@bep bep added this to the v0.52 milestone Nov 13, 2018

bep added a commit to bep/hugo that referenced this issue Nov 28, 2018

@bep bep closed this in #5481 Nov 28, 2018

bep added a commit that referenced this issue Nov 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment