Hi all, I want to use Markdown (Goldmark) to write some text with figures, tables and references. What do you suggest I use to have figures and table number automatically adjust as I edit and move things around, and what reference editor should I use so the bibliography is automatically generated?


What is your question? Goldmark is the default markdown parser of Hugo. So… use… Goldmark? Hugo has in version 0.93 now Goat and Mermaid graphs… if that is “figures” for you. What is a table-number?

The question about a reference editor is interesting. I never thought about this. I type all my content up in Joplin (a note taking app) and then copy it over and didn’t run yet into compatibility issues.

Bibliography is not something Hugo does yet. That is probably something you will solve via a shortcode.

Better fitting answers with a better explanation what you want to achieve.

Thanks so much davidsneighbour for you answer. I’m new to HUGO and Markdown.

My question was whether it’s possible to write text in Goldmark and use tools to have figure # and table # automatically update as you add or move text/figures around. That would prevent renumbering everything all the time.

Thanks for the tip re: bibliography. I was wondering if there’s a possibility to work with say Zotero or other tools to help with citations.

Thanks again for your reply.

I’m assuming you have the same kind of functionality in mind as LaTeX provides. Goldmark is not and will probably never be able to provide it, because the syntax would be way to complicated for a simple markup language. The only option are Hugo’s shortcodes as davidsneighbour already mentioned. They include the .Ordinal variable and would allow to subsequently number shortcodes on one page — but not on a whole website. And before you start coding shortcodes — I would at first sight not recommend this to a HUGO and Markdown beginner, it’s a complex task. And generally I have doubts, that identification numbers are a good way to structure your content on a web project like you would in a latex document. Anchors would be much more suitable to reference specific content. You can add them as attribute after a Markdown block like {#table-id}.

You could use CSS counters and the contents attribute

1 Like

Yes, for counters my answer would be CSS3

For other things, have a look at Render Hooks and Shortcodes.

Just throwing one more option out there. It might work really easily if you are already using Emacs.

I write my posts in Org mode which I export to a mix of Markdown + HTML that Hugo can parse, using an Emacs/Org package ox-hugo1.

The Org mode Emacs-Lisp magic combines the passive markup syntax of Org mode with stuff like linking figures, tables, code snippets, etc., auto-numbering them, and much more.

Here’s an example of what a recent post of mine looks like in Org mode with the syntax-highlighting, etc. done in Emacs.

  • Here is the Markdown export done by ox-hugo that then gets used by Hugo.
  • And here’s the final product created by Hugo.
    • On that post, you can see the figures auto-numbered and hyperlinked with unique anchors as well (I do not need to do that manually… it’s all Org mode :sunglasses: )
    • Related to other autonumbering option that @chrillek suggested, I am auto-numbering all my sidenotes on that post using just CSS (no JS). As I happens, I had written2 a post on Sidenotes and CSS recently.

1 Disclosure: I have developed that package.
2 Of course, that post was also written in Org mode, as are all the posts on my blog.

Thanks all of you for your replies. I will try the options explained.