Wowchemy-hugo-modules: Order of author is not maintained in publication

Created on 30 Apr 2020  路  11Comments  路  Source: wowchemy/wowchemy-hugo-modules

In a publication page, the ordered of the author list is not maintained. It is being shown in the alphabetical order.
Since this is a publication page, the order of the author list needs to be maintained
I am using academic version 4.8.

Screenshot from 2020-04-30 17-52-05
As you can see, in the index.md the authors are written in an order which is not followed.
Please help.

upstream

Most helpful comment

create layouts/partials dir in your root folder.
inside that dir, create a file named page_metadata_authors.html and paste this code in it.
```{{/* Display author list. */}}

{{- $taxonomy := "authors" }}
{{ with .Param $taxonomy }}
{{ $link_authors := site.Params.link_authors | default true }}
{{ range $index, $name_raw := . }}
{{- $profile_page := site.GetPage (printf "/%s/%s" $taxonomy .) -}}
{{- $name := $profile_page.Title | default $name_raw -}}
{{- if gt $index 0 }}, {{ end -}}

{{- if and $profile_page $link_authors -}}
{{$name}}
{{- else -}}
{{$name}}
{{- end -}}

{{- end -}}
{{- end -}}
```
This is supposed to work.

All 11 comments

I think it is happening because GetTerms uses order by clause.
I was able to get around this for now by changing page_metadata_authors.html in layouts/partials but this hack won't link to the author pages which is also a problem.

{{/* Display author list. */}}
{{/* If `authors` is set and is not empty. */}}
{{ if $.Params.authors }}
{{ $authorLen := len $.Params.authors }}
{{ if gt $authorLen 0 }}
  {{ range $k, $v := $.Params.authors -}}
    <span itemscope itemprop="author" itemtype="http://schema.org/Person">
      <span itemprop="name">
        {{ $link := ($.Site.GetPage (printf "/authors/%s" $v)).RelPermalink }}

      {{ $person_page_path := (printf "/author/%s" (urlize $v)) }}
      {{ $person_page := $.Site.GetPage $person_page_path }}
      {{ if $person_page }}
        {{ $person := $person_page.Params }}
        {{- printf "<a href=\"%s\">%s</a>" $link $person.name | safeHTML -}}

      {{- else -}}
                {{- printf "%s" $v  -}}
      {{- end -}}
      </span>{{- /* This comment removes whitespace */ -}}
    </span>
    {{- if lt $k (sub $authorLen 1) -}}, {{ end }}
  {{ end }}
{{ end }}
{{ end }}

@kaustabpal The Hugo bug only affects the development version of Academic in the master branch. If you revert to the official release tagged as v4.8.0, then it won't be affected.

@gcushen I installed the official release only. I followed the instructions from the website and installed using git.
Edit: I closed the issue by mistake. Sorry. i have reopened it.

@kaustabpal an update has just been made to revert the change which introduced the use of the buggy Hugo function. Therefore, if you update to the latest master, you'll pick up the workaround and get the correct order for authors.

Otherwise, you can also revert your install to the exact Git tag for v4.8.0 https://github.com/gcushen/hugo-academic/releases/tag/v4.8.0 . Note that if you have the master version, the version displayed in academic.toml will be outdated until the next official release.

Works beautifully. Thank you for your quick response and thankyou for this beautiful theme.

hi @gcushen - sorry for the beginner's question, and thanks for the great theme. I also ran into this issue for my new website. What is the recommended way to update to the latest master while maintaining all the custom website info? Thanks

@seanfw If you installed Academic Kickstart, use

git submodule update --remote --merge

Refer to this page

Hi @kaustabpal - thanks a lot for your reply. I tried that, but apparently
"branch is up to date with 'upstream/master'."
It was my impression from reading your conversation above that if my branch was up to date with master it would fix the author order issue, but it seems not to be the case. Any other suggestions or tips on what I may be doing wrong? Your advice is much appreciated!

To be clear, from within the academic-kickstart folder, I entered the following lines of code
git submodule update --remote --merge
cd themes/academic/
git checkout master

create layouts/partials dir in your root folder.
inside that dir, create a file named page_metadata_authors.html and paste this code in it.
```{{/* Display author list. */}}

{{- $taxonomy := "authors" }}
{{ with .Param $taxonomy }}
{{ $link_authors := site.Params.link_authors | default true }}
{{ range $index, $name_raw := . }}
{{- $profile_page := site.GetPage (printf "/%s/%s" $taxonomy .) -}}
{{- $name := $profile_page.Title | default $name_raw -}}
{{- if gt $index 0 }}, {{ end -}}

{{- if and $profile_page $link_authors -}}
{{$name}}
{{- else -}}
{{$name}}
{{- end -}}

{{- end -}}
{{- end -}}
```
This is supposed to work.

That worked @kaustabpal - thanks so much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jacebenson picture jacebenson  路  3Comments

halfrost picture halfrost  路  3Comments

gcushen picture gcushen  路  4Comments

petzi53 picture petzi53  路  4Comments

jooyoungseo picture jooyoungseo  路  3Comments