Example: Citations and Bibliography
This template includes a citation system for academic writing. References are numbered in order of first appearance and link to a bibliography section at the end of the post.
Basic Usage
Cite a single source with the r tag: Knuth's seminal work [1] is
essential reading for any computer scientist. Turing's foundational paper [2] asked whether machines can think. Shannon's information theory [3] underpins
all of modern communications.
Cite multiple sources at once with a comma-separated list: the transformer architecture [4] popularised deep learning [5] techniques that are now ubiquitous. You can also group citations together: [2, 3].
How It Works
The {r`key`} syntax is a build-time preprocessor tag — import ref as r from $lib/tags and the preprocessor replaces it with a <Ref> component that renders a numbered superscript link.
The <Bibliography> component at the bottom of the post reads the citation
order and fetches your JSON reference file. It only renders if at least one citation was used.
Setting Up Your References
Create a JSON file in static/references/ (or anywhere under static/)
with your reference data. Keys are the citation handles you use in {r`key`}.
// static/references/my-post.json
{
"smith2024": {
"authors": ["Jane Smith"],
"title": "My Great Paper",
"year": 2024,
"journal": "Nature",
"volume": "600",
"pages": "1–10",
"doi": "10.1038/example"
}
} Supported fields:
- authors — array of author name strings
- title — required
- year — publication year
- journal, volume, issue, pages — for journal articles
- booktitle, pages — for conference papers
- publisher, edition — for books
- doi, arxiv, url — rendered as clickable links
- note — freeform extra text
Then place the <Bibliography> component at the bottom of your post:
<Bibliography src="/references/my-post.json" />