jekyll-scholar icon indicating copy to clipboard operation
jekyll-scholar copied to clipboard

Broken anchors to jump to references?

Open f90 opened this issue 6 years ago • 3 comments

I have a blog post with some articles I reference, (see this URL https://dans.world/Spotify-internship/ )

Within the text, links get generated for the references to the citations, which get listed at the end of the article. However, these anchor links (in the form of "#BIBTEXKEY") do not do anything. They should be jumping to the respective citation at the bottom of the article, but I found that in the HTML code I cannot see any anchor tags getting generated (by using "a name=BIBTEXKEY" near the citation).

Is there a setting to activate the anchors or is this some bug?

f90 avatar Feb 22 '19 13:02 f90

The anchors are set (as id) in the reference. Are you perhaps using a custom reference template which does not use the reference parameter that is passed-in? In that case you can set an id/name attribute yourself using the key parameter (which should also be passed to the template).

inukshuk avatar Feb 22 '19 13:02 inukshuk

Thanks, you were exactly right, i changed

<b>{{entry.title}}</b>

to

<b id="{{entry.key}}">{{entry.title}}</b>

in my bibliography template html and it works. Now I have two related issues however. One is that when citing multiple references at once, it generates a link only to the first author that is cited. So when I write in markdown:

{% cite Huang2014 Stoller2018a %}

I get with apa style

<a href="#Huang2014">(Huang, Kim, Hasegawa-Johnson, &amp; Smaragdis, 2014; Stoller, Ewert, &amp; Dixon, 2018)</a>

and with IEEE style:

<a href="#Huang2014">[1], [2]</a>.

The other thing is that the link to the anchor does not change the browser bar URL, so pressing the back button makes me leave the page completely instead of going back to where i was reading before... Although that might be a server setting issue related to URL hiding?

f90 avatar Feb 22 '19 14:02 f90

I managed to get the desired jumping behaviour by using

<a name="{{entry.key}}"/>

although it's deprecated in HTML5... The other issue remains and is quite annoying if you click on a reference and it jumps to the other one.

f90 avatar Feb 22 '19 14:02 f90