Custom citation style with Jekyll Scholar

442 Views Asked by At

I use Jekyll with Jekyll Scholar to serve a personal blog.

For a specific use case, I would like to show citations in-line in the text with the style: Authors (Year) Title and nothing else. So for example I want to get the following citation style:

Gu et al. (2017) Non-Autoregressive Neural Machine Translation

from the bibtex entry in my bibliography shown below.

Is there a Citation Style Language style that allows me to do exactly this? Is this available for example in github.com/citation-style-language/styles/?

More generally, is there a way I can generate inline citations with arbitrary custom styles by specifying the fields I would like to include and in what format/order?


@misc{https://doi.org/10.48550/arxiv.1711.02281,
  doi       = {10.48550/ARXIV.1711.02281},
  url       = {https://arxiv.org/abs/1711.02281},
  author    = {Gu, Jiatao and Bradbury, James and Xiong, Caiming and Li, Victor O. K. and Socher, Richard},
  keywords  = {Computation and Language (cs.CL), Machine Learning (cs.LG), FOS: Computer and information sciences, FOS: Computer and information sciences},
  title     = {Non-Autoregressive Neural Machine Translation},
  publisher = {arXiv},
  year      = {2017},
  copyright = {arXiv.org perpetual, non-exclusive license}
}
1

There are 1 best solutions below

0
On

To show citations in-line in your Jekyll blog using the style "Authors (Year) Title", you can use the cite filter provided by Jekyll Scholar

  • For the key of the bibliography entry:
    {% cite gu2017non-autoregressive %}
  • For the URL of the bibliography entry:
    {% cite https://doi.org/10.48550/arxiv.1711.02281 %}

You can create a custom CSL style file and use it with Jekyll Scholar to generate citations in your blog posts as follows:

  1. Create your custom CSL style file
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" default-locale="en-US">
  <info>
    <title>Custom CSL style</title>
    <id>custom-csl-style</id>
  </info>
  <citation disambiguate-add-names="true" disambiguate-add-givenname="true">
    <layout delimiter=". ">
      <text value="("></text>
      <names variable="author">
        <name form="short" delimiter=", " and="symbol"/>
      </names>
      <text value=")"></text>
      <date variable="issued" form="text"/>
      <text value=" "></text>
      <text variable="title"/>
    </layout>
  </citation>
</style>
  1. Save this file as custom.csl.

  2. Install the jekyll-scholar-csl gem and add it to your Gemfile

  3. In your _config.yml file, set the csl option to the path of your custom CSL style file:

    scholar:
     csl: /path/to/your/custom.csl
    
  4. Use the {% cite gu2017non-autoregressive %} filter to display citations in your blog posts using the custom CSL style.