Auto center with caption for images in Hugo

Create a file: layouts/_default/_markup/render-image.html: 1 2 3 4 5 6 <figure class="align-center "> <img loading="lazy" src="{{ .Destination | safeURL }}#center" alt="{{ .PlainText }}" > {{ with .Text }} <figcaption><p>{{ . | safeHTML }}</p></figcaption> {{ end }} </figure> Then magic happens: 1 ![sample](/img/nmc-bin/RADAR_L3_MST_CREF_GISJPG_Tiles_CR_20250126_13_06_3_2_6.png) Render as: sample

 · 1 min · 45 words · ringsaturn

Deploy Hugo pages via GitHub Actions

 · 1 min · 124 words · ringsaturn

Add Mathjax to Hugo

Code copy&paste from Ataias Pereira Reis’s PR adityatelange/hugo-PaperMod#140 with some modifed on toggle option. Creat two files under layouts/partials/. Create math.html: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 <script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" > MathJax.Hub.Config({ tex2jax: { inlineMath: [['$', '$'], ['\\(', '\\)']], displayMath: [['$$', '$$']], processEscapes: true, processEnvironments: true, skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'], TeX: { equationNumbers: { autoNumber: "AMS" }, extensions: ["AMSmath.js", "AMSsymbols.js"] } } }); MathJax.Hub.Queue(function () { // Fix <code> tags after MathJax finishes running. This is a // hack to overcome a shortcoming of Markdown. Discussion at // https://github.com/mojombo/jekyll/issues/199 var all = MathJax.Hub.getAllJax(), i; for (i = 0; i < all.length; i += 1) { all[i].SourceElement().parentNode.className += ' has-jax'; } }); MathJax.Hub.Config({ // Autonumbering by mathjax TeX: { equationNumbers: { autoNumber: "AMS" } } }); </script> Create extend_head.html: ...

 · 1 min · 198 words · ringsaturn