How can I manage a publication list in Hugo, preferrably from Bibtex file?

Hi,
I’m investigating static site generators a bit and I am wondering how I would manage a publications list in this one.
Ideally, I would give a Bibtex .bib file, specify the page in markdown and then have it output there.

Google doesn’t deliver anything for “hugo bibtex”, so I am writing here. Is there anything available in this direction?
Do people pre-generate publications lists with other tools and include only the markdown result?
How is the extensibility of Hugo? Would it be easy to write a plugin that delivers this functionality? Is it possible to define scripts that should run before compilation (I suppose that would ruin the speed)?

Kind regards,
Matthias

1 Like

No Bibtex support.

Currently not extensible at all (if you look outside the templates and the shortcodes), but there are plans in this direction.

I guess you could store these lists in YAML, TOML or JSON – and generate them from a shortcode …

Jekyll has https://github.com/inukshuk/jekyll-scholar

It’s a natural approach for scholars: just copy/paste a bibtex entry to your page, it will be converted to html.

From its readme.md:

Once you have loaded Jekyll-Scholar, all files with the extension .bib or
.bibtex will be converted when you run Jekyll (don’t forget to add a YAML
header to the files); the file can contain regular HTML or Markdown and
BibTeX entries; the latter will be formatted by Jekyll-Scholar according to
the citation style and language defined in your configuration file.

For example, if you had a file bibliography.bib in your root directory:

---
---

References

@book{ruby,
 title     = {The Ruby Programming Language},
 author    = {Flanagan, David and Matsumoto, Yukihiro},
 year      = {2008},
 publisher = {O'Reilly Media}
}

It would be converted to bibliography.html with the following content:

<h1 id='references'>References</h1>

<p>Flanagan, D., &#38; Matsumoto, Y. (2008). <i>The Ruby Programming Language</i>. O&#8217;Reilly Media.</p>

+1 for this and more scholars publishing in HTML! Also thanks for the pointer to the jekyll-scholar extension.

They seem use a ruby implementation (https://github.com/inukshuk/citeproc-ruby) to process and convert .bibtex files.

So, from my (very basic) understanding we would need a citation processor library (“cite-proc”) written in go (or we would nedd to wrap another library via “system calls”, i guess). If i get it right, the aim might be to convert entries of a .bibtex documents into lines we append (those used / cited) to our .markdown files before that files goes through the hugo markdown processing engine. That way, one should be able to address these entries according to a custom cite syntax from within the markdown body.

I found a haskell lib called “pandoc” which should be able to convert “bibtex” to “markdown”, it already comes with a cite-proc extension: http://hackage.haskell.org/package/pandoc-citeproc

Does somebody know which markdown processing engine hugo employs? I couldn’t find the corresponding statements in the github readme or documentation pages (yet).

I just wanted to throw some more links in here as i also think hugo and bibtex should get together somehow.

Hugo uses Blackfriday for Markdown but supports Mmark as well.

Also supports asciidoc and reStructuredText by way of external processors.

Has anyone already made a site which uses a YAML bibliography for citing? I think it should be possibe to convert a Zotero or Mendeley bibliography via JSON or so to YAML. For Pandoc users it would be ideal if the citation key is as follows: [@foobar_2007]. With a little template magic it should be possible to insert a citation footnote on the given page and add the entry to a bibliography page.

1 Like

I was running into a similar problem and built a custom yaml data structure for my publications, you can find it in my repository. With some adaptions it could easily work with yaml generated based on exported bibliographies.

If you dig in my theme folder you will find the code to compile the data into APA format and a list markup (the result is visible on my website). I use identifiers based on dates in shortcodes to generate individual items out of the data file.

It works for my use case, but for scientific publishing it would certainly be nice if there was build in functionality for existing bibtex file, csl formats and citation keys. Sounds like a nice project idea to integrate such functionality in Hugo, I wouldn’t know where to start though.

3 Likes

Thanks for this hint.

I agree. A built-in solution should be based on bibtex and csl styles. That would be a nice Summer of Code project.

I found a solution using pandoc and hugo which might be a workaround.

Given you have a markdown file (input.md) with citations as you use it in a typical Pandoc project. Citations are referenced like this.

lorem ipsum[@foobar_2013]

@foobar_2013 ist the key pointing to the bibtex entry in your bibliography file yourbiblio.bib.

  1. Run pandoc on this file like this:
    pandoc input.md -t markdown-citations -s --bibliography yourbiblio.bib --csl yourstyle.csl -o output.md
    This will create a markdown file with normal footnotes and expanded citations.

    lorem ipsum[^1]

    [^1]: John Foobar. Lorem ipsum. Hometown, 2013

  2. Copy the output.md to content/post or where ever you want it, and run hugo server

You will recognize that the file output.md contains a list of publications, used for this text, at the end of the file. Put a headline in front of this list, something like # Bibliography. The footnotes are placed after this list at the very end of the file.

2 Likes

Another way, also pandoc related, would be to use pandoc-citeproc to convert the bibtex to a YAML file:

% pandoc-citeproc -y references.bib

… and then use the YAML file as data which could be rendered using a Hugo template.

1 Like

If you or anyone uses Org mode, this might be useful – I recently added BibTeX support to the ox-hugo package for Emacs. It parses the citations using a pandoc command similar to the one in your reply. But everything happens transparently. The user just needs to use Pandoc Citations in Org mode and export it using the usual command.

Pandoc parsing happens if needed, if user enabled Pandoc support.

3 Likes