Skip to content

Citation support in the themes: a "Cite this" control driven by CITATION.cff #359

Description

@mmcky

Background

Suggestion out of a conversation with Simon Scheidegger about the Deep Learning for Solving and Estimating Dynamic Economic Models course site (itself a MyST site): our published lecture sites should hand the reader a ready-made citation — driven by a CITATION.cff in the repo, and surfaced on the site in a range of formats (BibTeX, APA, RIS, and the raw .cff).

#342 already covers adding CITATION.cff files to the book-* repos so GitHub renders its "Cite this repository" sidebar button. This issue is the other half of the same idea: what the themes do with that metadata, so a reader landing on the published site never has to go to GitHub to work out how to cite it. Scope is quantecon-theme.mystmd, quantecon-book-theme, and the upcoming book and community-lecture themes.

What exists today

mystmd (and therefore Jupyter Book ≥ 2)

Jupyter Book 2 is built on the MyST engine, so whatever mystmd offers is what JB2 offers.

Capability Status
Generate CITATION.cff from myst.yml Yes — a cff export target, landed in myst-cli 1.3.3 (Aug 2024) via jupyter-book/mystmd#1397
Read CITATION.cff into myst.yml No — requested in jupyter-book/mystmd#2401 (open, Nov 2025)
Render a "cite this" affordance on the site No — nothing citation-related in the @myst-theme packages we consume

The export is declared in project frontmatter, and myst build --cff writes the file from project (or page) frontmatter — authors, title, DOI, license, abstract — through the cffjs library. CFF fields that have no myst.yml equivalent go in the export block:

version: 1
project:
  ...
  exports:
    - format: cff
      date-released: '2026-08-20'

Two consequences worth noting. First, the direction is one-way — myst.yml is the source of truth and the .cff is a build artifact; jupyter-book/mystmd#2401 is the upstream issue to watch if we would rather make the .cff canonical and have myst.yml extend from it. Second, because the export produces a real file with an id:, it can be referenced from the site's downloads: config — so a MyST site can already offer CITATION.cff as a download with no theme change at all. That gets us the raw file, not the "pick your format" experience.

Jupyter Book 1 (Sphinx) — quantecon-book-theme

There is no CITATION.cff support anywhere in the JB1 stack. Citation support in JB1 means sphinxcontrib-bibtex — the {cite} role and a {bibliography} directive over a .bib file — which is about citing other works from within the text, not about how to cite the lecture series itself. Neither sphinx-book-theme nor pydata-sphinx-theme ships a "cite this" component.

So everything on this side is ours to build: a small Sphinx extension that reads CITATION.cff from the repo root, converts it, and exposes the result to the theme's layout.html. cffconvert (Python, CLI and importable) converts CFF to BibTeX, APA-like, RIS, EndNote, CodeMeta, Zenodo JSON and schema.org JSON. Important caveat: it does not convert the references or preferred-citation keys — which matters directly, because the files proposed in #342 lean on preferred-citation to point at the published book.

Our repos right now

None of lecture-python.myst, lecture-python-advanced.myst, lecture-jax, lecture-datascience.myst, lecture-julia.myst, quantecon-theme.mystmd or quantecon-book-theme has a CITATION.cff. QuantEcon.py does, and gets the GitHub sidebar button for free as a result.

The gap

Generation is solved on the MyST side and absent on the Sphinx side. Presentation is unsolved on both. The thing Simon actually suggested — a reader-facing control that yields a correct citation in the format they want — is theme work in both stacks, and no upstream component exists to drop in.

Proposed scope

  1. quantecon-theme.mystmd — add a "Cite this" control to the project header. app/components/ProjectFrontmatter.tsx is the natural home, alongside the author list and the last-changed control. Two candidate sources: build the formats client-side from the frontmatter the theme already receives, or read a generated CITATION.cff. Frontmatter-driven is preferable — it works for every project using the theme without each repo having to ship or regenerate a file.
  2. quantecon-book-theme — the equivalent control for the JB1 sites, which needs the Sphinx extension described above (CFF in, converted formats out, injected into layout.html).
  3. Upcoming book theme and community-lecture theme — build the same component in from the start, as part of the theme baseline rather than a later retrofit.
  4. A shared spec first — agree the fields, the formats offered, and where the control lives before either implementation starts, so the two stacks do not diverge in wording or placement.

Open questions

  • Source of truth. Decided: the committed CITATION.cff is the source of truth, because it integrates with GitHub directly at the repo level and lines up with Add citation support (CITATION.cff) across book-* repositories #342. See the comment below for what that means for each stack.
  • Which formats. BibTeX and APA cover most of the audience; RIS adds Zotero/Mendeley/EndNote import; the raw .cff is cheap to include. Anything beyond that is probably noise.
  • What are we citing. Decided: it depends on document type. A book cites as a whole work; a lecture series is better cited per page, since readers reference an individual lecture rather than the series. So the control's behaviour is keyed off document type rather than being one fixed shape. See the comment below.
  • DOIs. Worth minting Zenodo DOIs for the lecture series (as QuantEcon.py does), so the citation resolves to something permanent? That decision is upstream of the theme work.
  • Machine-readable metadata. Should the same metadata also emit schema.org JSON-LD and/or Google Scholar <meta> tags, so the sites are indexable as scholarly works? Cheap to add once the data is in the theme.
  • preferred-citation. If we adopt the Add citation support (CITATION.cff) across book-* repositories #342 pattern (repo metadata plus preferred-citation for the published book), the Sphinx converter needs to handle a key cffconvert skips.

Task list

  • Agree the shared citation spec (formats, placement, wording) — source of truth and citation granularity now decided, see comments
  • Write the CITATION.cff reader as a build-time MyST transform plugin, following plugins/git-metadata.mjs
  • Write the Sphinx counterpart beside get_git_last_modified in quantecon-book-theme
  • Separately, decide whether to de-duplicate authors/title out of myst.yml (upstream extends, or a local pre-build config fragment)
  • Define the per-page citation composition rules for lecture series (which CFF fields carry over, what the page contributes)
  • Prototype the "Cite this" control in quantecon-theme.mystmd
  • Sphinx extension to read and convert CITATION.cff, plus the control in quantecon-book-theme
  • Fold the component into the upcoming book and community-lecture themes as baseline
  • Add CITATION.cff to the lecture repos, coordinated with Add citation support (CITATION.cff) across book-* repositories #342 for the book-* repos
  • Track Extend Myst.yml from CITATION.cff jupyter-book/mystmd#2401 upstream — now a dependency rather than a nice-to-have, given the decision above

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions