Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Custom Backend (Handlebars)

The Custom backend uses Handlebars templates to render citations and bibliography entries. This gives you full control over the HTML output, including custom layouts, interactive elements, and styling.

When to Use Custom Backend

  • You need custom HTML layouts for bibliography entries
  • You want interactive elements (copy buttons, collapsible details, tooltips)
  • You need to match a specific visual style not available in standard CSL formats
  • You want to embed custom JavaScript functionality

Configuration

The Custom backend is the default. No backend option is needed:

[preprocessor.bib]
bibliography = "refs.bib"

# Optional customization
hb-tpl = "render/references.hbs"      # Bibliography entry template
cite-hb-tpl = "render/citation.hbs"   # Inline citation template
css = "render/style.css"              # Custom CSS
js = "render/script.js"               # Custom JavaScript

Template Variables

Bibliography Entry Template (hb-tpl)

Available variables for rendering each bibliography entry:

VariableTypeDescription
citation_keyStringUnique identifier for the entry
titleStringEntry title
authorsArrayList of authors as [[Last, First], ...]
pub_yearStringPublication year
pub_monthStringPublication month
urlStringURL if available
summaryStringAbstract/summary
indexNumberCitation order (1-based)
entry_typeStringType: article, book, inproceedings, etc.
doiStringDOI if available
pagesStringPage numbers
volumeStringVolume number
issueStringIssue number
publisherStringPublisher name
addressStringPublisher location
editorArrayEditors (same format as authors)
editionStringEdition
seriesStringSeries name
noteStringAdditional notes

Citation Template (cite-hb-tpl)

Available variables for inline citations:

VariableTypeDescription
pathStringRelative path to bibliography page
item.citation_keyStringCitation key
item.titleStringEntry title
item.authorsArrayAuthors
item.pub_yearStringYear
item.indexNumberCitation order
(all other item.* fields)Same as bibliography template

Example Templates

Simple Bibliography Entry

<div class="bib-entry" id="{{citation_key}}">
  <span class="bib-index">[{{index}}]</span>
  <span class="bib-authors">
    {{#each authors}}{{#unless @first}}, {{/unless}}{{this.[1]}} {{this.[0]}}{{/each}}
  </span>
  <span class="bib-title">"{{title}}"</span>
  {{#if pub_year}}<span class="bib-year">({{pub_year}})</span>{{/if}}
  {{#if url}}<a href="{{url}}">[link]</a>{{/if}}
</div>

Simple Citation

<a href="{{path}}#{{item.citation_key}}">[{{item.index}}]</a>

Citation with Hover Preview

<a href="{{path}}#{{item.citation_key}}"
   class="citation"
   title="{{item.title}} ({{item.pub_year}})">
  [{{item.index}}]
</a>

Bibliography Entry with Copy Button

<div class="bib-entry" id="{{citation_key}}">
  <div class="bib-header">
    <span class="bib-index">[{{index}}]</span>
    <button class="copy-btn" onclick="copyBib('{{citation_key}}')">Copy</button>
  </div>
  <div class="bib-content">
    <strong>{{title}}</strong><br>
    {{#each authors}}{{this.[1]}} {{this.[0]}}{{#unless @last}}, {{/unless}}{{/each}}
    {{#if pub_year}}({{pub_year}}){{/if}}
  </div>
</div>

Custom CSS

Style your bibliography with CSS:

.bib-entry {
  margin: 1em 0;
  padding: 0.5em;
  border-left: 3px solid #4a9eff;
}

.bib-index {
  font-weight: bold;
  color: #4a9eff;
}

.bib-title {
  font-style: italic;
}

.citation {
  color: #4a9eff;
  text-decoration: none;
}

.citation:hover {
  text-decoration: underline;
}

Custom JavaScript

Add interactivity with JavaScript:

function copyBib(key) {
  const entry = document.getElementById(key);
  const text = entry.querySelector('.bib-content').innerText;
  navigator.clipboard.writeText(text);
}

Full Configuration Example

[preprocessor.bib]
bibliography = "references.bib"
title = "References"
render-bib = "cited"          # Only show cited entries
order = "index"               # Order by citation appearance
hb-tpl = "render/refs.hbs"
cite-hb-tpl = "render/cite.hbs"
css = "render/bib.css"
js = "render/bib.js"

Tips

  • Use {{#if field}}...{{/if}} to conditionally render optional fields
  • Use {{#each authors}}...{{/each}} to iterate over the author list
  • Inside {{#each authors}}, access {{this.[0]}} (last name) and {{this.[1]}} (first name)
  • Add id="{{citation_key}}" to entries for citation linking
  • Use {{index}} for numbered citations