Pre-render LaTeX in hugo at build #13

Open
opened 2026-05-16 20:07:18 +02:00 by gribse · 1 comment
Owner

To save on page size, pre-render LaTeX.
Today the whold library (~1mb) is served on every page...

I tried and failed on the old repo. Retry !

Useful resources :

https://gohugo.io/render-hooks/passthrough/
https://www.andyleemitchell.com/posts/latex-in-hugo/

To save on page size, pre-render LaTeX. Today the whold library (~1mb) is served on every page... I tried and failed on the old repo. Retry ! Useful resources : https://gohugo.io/render-hooks/passthrough/ https://www.andyleemitchell.com/posts/latex-in-hugo/
Author
Owner

Previous notes :

MathJax js LaTeX library is 1mb. that's too much (goal : 1mb max on every page)
KaTex js LaTeX library is only 0.26 mb, but that is still uncessary. Also it has trouble rendering inline LaTeX like a + b = c when there also is $ in the text.

It is possible to use render hooks to render latex server side, thus ligntening download size

https://gohugo.io/functions/transform/tomath/

Previous notes : MathJax js LaTeX library is 1mb. that's too much (goal : 1mb max on every page) KaTex js LaTeX library is only 0.26 mb, but that is still uncessary. Also it has trouble rendering inline LaTeX like $a + b = c$ when there also is $ in the text. It is possible to use render hooks to render latex server side, thus ligntening download size https://gohugo.io/functions/transform/tomath/
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
gribse/blog-hugo#13
No description provided.