Math Typesetting

Mathematical formulas written in LaTeX notation can be rendered to HTML on the client side by bundling the KaTeX library with the website.

Rendering can take place either globally, or in specific locations using a built-in shortcode.

  1. Math can be rendered globally or on a per-page basis by setting the math parameter to true in the site configuration or on specific pages, and by enabling the passthrough extension in the site configuration.

  2. If the math parameter is set to false, mathematical formulas can still by rendered by surrounding them with the math shortcode:

    {{% math %}}
    Inline formulas such as $y=ax+b$ are supported, displayed formulas as well:
    
    $$e^{i\pi}+1=0$$
    {{% /math %}}

As of 2024, it is not yet possible to render math on the server side with Hugo.

Note: Use the online reference of Supported TeX Functions

Examples

Inline math: $\varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887โ€ฆ$

Block math: $$ \varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } } $$

Emoji Support

Emoji can be enabled in a Hugo project in a number of ways.

The emojify function can be called directly in templates or Inline Shortcodes.

To enable emoji globally, set enableEmoji to true in your site’s configuration and then you can type emoji shorthand codes directly in content files; e.g.

๐Ÿ™ˆ :see_no_evil: ๐Ÿ™‰ :hear_no_evil: ๐Ÿ™Š :speak_no_evil:


The Emoji cheat sheet is a useful reference for emoji shorthand codes.


N.B. The above steps enable Unicode Standard emoji characters and sequences in Hugo, however the rendering of these glyphs depends on the browser and the platform. To style the emoji you can either use a third party emoji font or a font stack; e.g.

.emoji {
  font-family: Apple Color Emoji, Segoe UI Emoji, NotoColorEmoji, Segoe UI Symbol, Android Emoji, EmojiSymbols;
}

Page Bundle

Occaecat aliqua consequat laborum ut ex aute aliqua culpa quis irure esse magna dolore quis. Proident fugiat labore eu laboris officia Lorem enim. Ipsum occaecat cillum ut tempor id sint aliqua incididunt nisi incididunt reprehenderit. Voluptate ad minim sint est aute aliquip esse occaecat tempor officia qui sunt. Aute ex ipsum id ut in est velit est laborum incididunt. Aliqua qui id do esse sunt eiusmod id deserunt eu nostrud aute sit ipsum. Deserunt esse cillum Lorem non magna adipisicing mollit amet consequat.

Bryce Canyon National Park

Sit excepteur do velit veniam mollit in nostrud laboris incididunt ea. Amet eu cillum ut reprehenderit culpa aliquip labore laborum amet sit sit duis. Laborum id proident nostrud dolore laborum reprehenderit quis mollit nulla amet veniam officia id id. Aliquip in deserunt qui magna duis qui pariatur officia sunt deserunt.