Skip to content
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

Closed
zombiezen opened this issue Jul 16, 2018 · 4 comments · Fixed by #5481
Closed

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

zombiezen opened this issue Jul 16, 2018 · 4 comments · Fixed by #5481
Milestone

Comments

@zombiezen
Copy link

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.

@bep
Copy link
Member

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.

@stale
Copy link

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
@zombiezen
Copy link
Author

I don't believe this bug has been fixed.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants