Closed jessebett closed 5 years ago
Yes, I think an option to disable links on authors' names could be a great improvement. Moreover it is really easy to implement. I would be happy to provide help if it is needed.
We could also add an option to disable links on publications' title. In our case, we use publication only as a list of articles. It don't really make sense to link titles to pages which contains just the title and authors of the publication.
I recently started using this theme and I was looking for an option to link to co-authors homepages instead of having an author page created automatically. I agree with @jessebett here. In addition I'd like to have the possibility to link to an external page like research gate, google scholar or the co-author's homepage. I'm not yet used to Hugo syntax but I am willing to give it a try if someone could drop a few hints on the structure of the theme and which files to consider.
Hello,
I think you should look at this files:
themes/academic/layouts/partials/li_citation.html
: this page shows the title, date, abstract of each publication. It calls page_metadata_authors.html in order to show authors' namesthemes/academic/layouts/partials/page_metadata_authors.html
: this is the page responsible for creating links on the authors names.You should not edit these files directly but duplicating them:
themes/academic/layouts/partials/page_metadata_authors.html
-> layouts/partials/page_metadata_authors.html
Hugo uses files at the root of your folder if they exist and search for them in the theme folder otherwise (Academic documentation about overriding templates).
It will be easier to make change later and to update Academic if you have duplicated them.
Just a question do you prefer adding links to co-authors homepages on all publication markdowns files or creating a unique list of co-authors in the config file?
If you create a variable in params.toml
you can access it
$.Site.Params.VARIABLENAME
in li_citation or page_metadata_authors.If you create a varialble in publication markdown file, you can access it
.Params.VARIABLENAME
in li_citation.$.Params.VARIABLENAME
in page_metadata_authors.I hope it was clear. If you have questions, I will be happy to help you.
Do you want me to provide what I did on my server ? I can also implement linking to personal websites for co-authors. If someone is interested, I will do a pull request tomorrow.
I'm interested in linking to co-author's personal websites from each of my publications. I'm new to Hugo, so I'm not too sure what's a clean way to implement this, so I'd certainly be interested in seeing what others have done.
As @FramboisePi pointed out, you can create a new variable in your individual publication .md files, and change the li_citation
partial file accordingly.
A simple way of getting rid of author pages/links is therefore to:
(1) Delete the authors
parameter in your .md files and replace it with a new variable, eg. author_list
. This can be a text string containing all authors names, without or without html formatting. For instance: "Smith J, <b>Spencer M</b>, Doe J
if you want to highlight the second author in bold font.
(2) Make a copy of themes/academic/layouts/partials/li_citation.html
and place it in your root folder (creating the layouts
and partials
folders if necessary).
(3) Edit the copied li_citation
file by deleting {{ partial "page_metadata_authors" . }}
and replacing it with another html element that will print out the value of the author_list
variable you defined earlier such as <span class="author_list">{{- .Params.author_list | markdownify -}}</span>
.
An option to disable publication link and author link will be very helpful.
@FramboisePi I would love help on how to do this, if you're offering. Trying to disable author link and can't get step (3) outlined by @pjbouchet to work.
Hi,
@pjbouchet's message is a way to link authors to external websites and not disable link.
In order to disable publication and author links, you need to do the following changes:
Add these two variables in [publication] in config/_default/params.toml
[publications]
# ... PREVIOUS CODE ... #
# Link the title of the publication to the publication
links_title = false
# Link the authors of the publication to the list of publication made by this author
links_authors = false
themes/academic/layouts/partials/li_citation.html
to layouts/partials/li_citation.html
. Create the layouts folder at the root and then partials if necessary.Replace
<a href="{{ .RelPermalink }}" itemprop="name">{{ .Title }}</a>.
by
{{ if site.Params.publications.links_title }} <!-- Create a link on the publication title -->
<a href="{{ .RelPermalink }}" itemprop="name">{{ .Title }}</a>.
{{ else }}
<a itemprop="name">{{ .Title }}</a>.
{{ end }}
This code is present two times: for {{/* APA Style */}}
and for {{/* MLA Style */}}
so you need to make the change twice.
themes/academic/layouts/partials/page_metadata_authors.html
to layouts/partials/page_metadata_authors.html
.Replace
<a href="{{.RelPermalink}}">{{$name}}</a>
by
{{ if site.Params.publications.links_authors }} <!-- Create a link for authors of the publication -->
<a href="{{.RelPermalink}}">{{$name}}</a>
{{- else -}}
<a>{{$name}}</a>
{{- end -}}
I hope this is clear. If you have any question, I will be happy to help you.
I'm confused, in step 2, where I'm copying themes/academic/layouts/partials/li_citation.html
to. Is it to my root directory (i.e., ~/layouts/partials/li_citation.html
)?
This is, in general, something confusing to me about using Hugo. What is the difference between modifying theme
files in the theme
folder, versus the root directory?
@hail2thief If you modify theme files directly, then any modifications you make will be overwritten when you update Academic in the future. Hugo looks for layout files in a specific order (see https://gohugo.io/templates/lookup-order/), so that if you copy the theme files to your website root, they will be read instead of the original theme ones. See also https://gohugo.io/templates/lookup-order/
And to clarify - the solutions I suggested can be used to both disable links and add custom links to co-authors' own personal websites, if necessary. All it does is replace the theme's authors parameter with one you define yourself - and which can be a text string (no links), a formatted text string as in the example I gave (eg. with some names in bold font), or one with links (you can use the <a href>
syntax to add links to personal websites if you like). As @FramboisePi pointed out, you need to make the edits twice as the li_citation
file has code for both the APA and MLA citation styles (or at least do it for the style you're using).
Hope this clarifies things.
Thanks for the clarification @pjbouchet! @FramboisePi 's solution is now working great for the title links, and I'll wait to see what he posts re: disabling the author links.
Your right @pjbouchet. I should have said that step 1 was not necessary to disable links 😌. Your method is really great and will allow further customizations, but it is a bit harder than modifying existing code. To be honest, I did not think about it.
A question, do you think I should try to submit a pull request to @gcushen? In my opinion, it would be useful to have this option in Academic, as it allow more customizations for websites.
You should replace $.Site.Params.publications.links_title
by site.Params.publications.links_title
in step 2.
It was easier as I thought, I updated my messages with code for author's links.
Perfect!. Thanks!
A question, do you think I should try to submit a pull request to @gcushen? In my opinion, it would be useful to have this option in Academic, as it allow more customizations for websites.
+1 for a PR to have an option to disable links on authors
Returning to my earlier request for tips on linking to external websites for each co-author, I just realized I hadn't tried the obvious thing: just using Markdown inside the existing authors list. It turns out this works for my use case, where I don't actually care to have a profile page on my site for any of my co-authors. In case any other newcomers to might find it helpful, you can see here what I did: https://github.com/VictorYing/personal-website/commit/58f7dd4708fe1bc7622204ef2dfec4a52c460425 I didn't end up doing any copying/modification/overriding of the theme's design. The theme is still generating a "profile page" for each co-author, and unfortunately this doesn't handle markdown very well (e.g. https://www.victoraying.com/authors/daniel-sanchezhttp/people.csail.mit.edu/sanchez/), but as long as there are no links to these profile pages, it shouldn't really matter.
For everybody who simply wants to disable links, the most natural way to do this might be to not only disable the link, but to disable the generation of profile pages for any co-author that doesn't actually have an "account" i.e. to disable the generation of any profile pages for any co-author that does not have a file within /content/authors/
. I can't help but notice some logic to avoid generating links if no profile pages exist is already there in page_metadata_authors
:
https://github.com/gcushen/hugo-academic/blob/a6da45d7fd77243deddaf8268df987a5f7c829ca/layouts/partials/page_metadata_authors.html#L10-L14
Unfortunately I haven't yet figured out what controls the automatic generation of profile pages.
Hi,
I created a pull request with the modifications said earlier. The only difference is that options are called disable_links_title
and disable_links_authors
in order to make them optional.
I would be happy to improve it with your suggestions.
@VictorYing your idea is probably better for authors links but for the moment I don't how to do this. Have you found something new on the subject?
Has anyone tried to disable author links recently - with a newer version of the academic theme? I tried the steps of @FramboisePi and @pjbouchet which took out the author links on the listing in the recent publication section on the homepage, but entirely removed the authors on the publication page. I cannot see any link_authors option in the params.yaml, and i cant find any params.toml file.
@guyabel
Has anyone tried to disable author links recently - with a newer version of the academic theme? I tried the steps of @FramboisePi and @pjbouchet which took out the author links on the listing in the recent publication section on the homepage, but entirely removed the authors on the publication page. I cannot see any link_authors option in the params.yaml, and i cant find any params.toml file.
You might need to copy this file to layouts/partials/
, then edit L12-L16:
{{- if .RelPermalink -}}
<a href="{{.RelPermalink}}">{{.LinkTitle}}</a>
{{- else -}}
{{ .LinkTitle }}
{{- end -}}
into
{{ .LinkTitle }}
then rebuild the site, and the link should be disabled.
@lonizing
@guyabel
Has anyone tried to disable author links recently - with a newer version of the academic theme? I tried the steps of @FramboisePi and @pjbouchet which took out the author links on the listing in the recent publication section on the homepage, but entirely removed the authors on the publication page. I cannot see any link_authors option in the params.yaml, and i cant find any params.toml file.
You might need to copy this file to
layouts/partials/
, then edit L12-L16:{{- if .RelPermalink -}} <a href="{{.RelPermalink}}">{{.LinkTitle}}</a> {{- else -}} {{ .LinkTitle }} {{- end -}}
into
{{ .LinkTitle }}
then rebuild the site, and the link should be disabled.
Thanks. Worked a treat!
It appears a recent update added a feature to have the names of authors on publications as hyperlinks which take you to a page listing their publications. I don't think this behaviour should be enabled by default, and at least should have an obvious way to disable it.
My reasoning is that myself and others use this template for a personal academic website, not a homepage for a group. While this feature may be useful for research groups, it is strange to have on a personal site.
Further, within markdown I indicate first authorship with an
*
and also bold my own name in the author list. The current implementation of this feature does not respect either of these. If I put an*
after a first author's name, the author hyperlink directs to an internal page withauthorsname*
which is distinct from the pages directed to from other publications just containingauthorsname
not first authored. Likewise, the markdown bolding on my name in the authors list takes me to a author page, for myself, which is already undesirable behaviour for a personal website. Further, the markdown bolding in the author's list is not respected in the title of the target author page, so that has a title**myname**
.Again, I think this feature should be disabled by default, and have the option to enable it easily with a boolean option in the publications widget configuration.