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

Page.GetTerms order is inconsistent and overrides term order in front matter #7213

Closed
gcushen opened this issue Apr 26, 2020 · 3 comments · Fixed by #7389
Closed

Page.GetTerms order is inconsistent and overrides term order in front matter #7213

gcushen opened this issue Apr 26, 2020 · 3 comments · Fixed by #7389
Milestone

Comments

@gcushen
Copy link

gcushen commented Apr 26, 2020

The implementation in #6905 differs in behaviour to the previous approach and ignores the order that the user defined the terms.

This causes issues in sites where the order of terms is important, such as when displaying page authors from an author taxonomy.

See the reports at

The goal in #6905 was to be able to rewrite

{{ $taxo := "tags" }} <!-- Use the plural form here -->
<ul id="{{ $taxo }}">
    {{ range .Param $taxo }}
        {{ $name := . }}
        {{ with $.Site.GetPage (printf "/%s/%s" $taxo ($name | urlize)) }}
            <li><a href="{{ .Permalink }}">{{ $name }}</a></li>
        {{ end }}
    {{ end }}
</ul>

as something like:

<ul>
    {{ range (.GetTerms "tags") }}
        <li><a href="{{ .Permalink }}">{{ .LinkTitle }}</a></li>
   {{ end }}
</ul>

However, the order of GetTerms differs to the earlier approach and ignores the order that the user defined the terms.

The order is very important to users when using taxonomies for things such as authors. For example, users expect if they define someone as the main author of a page, Hugo respects the order and lists that author first.

It appears that GetTerms ignores the order of terms defined in a pages front matter and there is no way for user to workaround this without fixing the order in Hugo itself to respect the order defined in the front matter and be consistent with the earlier approach.

What version of Hugo are you using (hugo version)?

Hugo Static Site Generator v0.69.2/extended darwin/amd64

Does this issue reproduce with the latest release?

Yes

gcushen added a commit to HugoBlox/hugo-blox-builder that referenced this issue Apr 30, 2020
Hugo bug causes authors not to be listed in the order in which they were defined in the front matter.

See Hugo bug report at gohugoio/hugo#7213

This commit partially reverts f78feef where the code was refactored to use Page.GetTerms for authors.
@Aariq
Copy link

Aariq commented May 26, 2020

This breaks the author order for publications on my website in a way which could be misconstrued as disingenuous. Would be great to get the old behavior back.

@bep bep added the Bug label Jun 15, 2020
@bep bep added this to the v0.73 milestone Jun 15, 2020
@bep
Copy link
Member

bep commented Jun 15, 2020

I will try to fix this, but note that the order isn't "inconsistent" or random or anything

bep added a commit to bep/hugo that referenced this issue Jun 15, 2020
Preserve the order from front matter, which would be behaviour when doing this manually (before GetTerms).

Fixes gohugoio#7213
bep added a commit to bep/hugo that referenced this issue Jun 15, 2020
Preserve the order from front matter, which would be behaviour when doing this manually (before GetTerms).

Fixes gohugoio#7213
bep added a commit to bep/hugo that referenced this issue Jun 15, 2020
Preserve the order from front matter, which would be behaviour when doing this manually (before GetTerms).

Fixes gohugoio#7213
@bep bep closed this as completed in #7389 Jun 15, 2020
bep added a commit that referenced this issue Jun 15, 2020
Preserve the order from front matter, which would be behaviour when doing this manually (before GetTerms).

Fixes #7213
muenchhausen pushed a commit to muenchhausen/hugo that referenced this issue Jun 24, 2020
Preserve the order from front matter, which would be behaviour when doing this manually (before GetTerms).

Fixes gohugoio#7213
muenchhausen pushed a commit to muenchhausen/hugo that referenced this issue Jun 24, 2020
Preserve the order from front matter, which would be behaviour when doing this manually (before GetTerms).

Fixes gohugoio#7213
YoungWilliamZ pushed a commit to YoungWilliamZ/hugo-academic that referenced this issue Jul 29, 2020
Hugo bug causes authors not to be listed in the order in which they were defined in the front matter.

See Hugo bug report at gohugoio/hugo#7213

This commit partially reverts f78feef where the code was refactored to use Page.GetTerms for authors.
@github-actions
Copy link

github-actions bot commented Feb 1, 2022

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 1, 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.

3 participants