From 6281f6661d9fa230f5cb886c7314f2dd8bbf5b73 Mon Sep 17 00:00:00 2001 From: "Lin, Chiang-Yu" <110763842+RxChi1d@users.noreply.github.com> Date: Thu, 8 May 2025 03:21:33 +0800 Subject: [PATCH] Enable Goldmark passthrough extension for math rendering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In Hugo v0.132.0, the Goldmark passthrough extension was introduced to preserve raw Markdown text within designated delimiters, ensuring that MathJax or KaTeX can render formulas correctly. With this configuration in place, you no longer need to manually escape characters inside math expressions (for example, \\ → \\\\ or x_y → x\_y). According the official document of Hugo: - [mathematics/#step-1](https://gohugo.io/content-management/mathematics/#step-1) - [Passthrough render hooks](https://gohugo.io/render-hooks/passthrough/) --- config/_default/hugo.toml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/config/_default/hugo.toml b/config/_default/hugo.toml index 85d63a1a..6100a56c 100644 --- a/config/_default/hugo.toml +++ b/config/_default/hugo.toml @@ -67,3 +67,12 @@ enableEmoji = true name = 'fragmentrefs' type = 'fragments' weight = 10 + +[markup] + [markup.goldmark] + [markup.goldmark.extensions] + [markup.goldmark.extensions.passthrough] + enable = true + [markup.goldmark.extensions.passthrough.delimiters] + block = [['\[', '\]'], ['$$', '$$']] + inline = [['\(', '\)']]