Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Hugo math equation support #589

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# TODO: Consider renaming this file to "hugo.yaml" in accordance with
# recommendations since v0.109 of Hugo.

# TODO: Consider splitting config into separate files in a "config/"
# directory hierarchy. See
# <https://gohugo.io/getting-started/configuration/#recursive-parsing>.

disableKinds:
- taxonomy
theme:
Expand All @@ -6,10 +13,27 @@ params:
colorScheme: auto # can be auto (browser setting), light, or dark
images:
- /images/logo.svg
math: true
navColor: blue
font:
name: "Lato"
sizes: [400, 900]
plausible:
dataDomain: null
javaScript: "https://views.scientific-python.org/js/script.js"

# Math equations.
markup:
goldmark:
extensions:
passthrough:
delimiters:
block:
- - \[
- \]
- - $$
- $$
inline:
- - \(
- \)
enable: true
8 changes: 5 additions & 3 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
<!-- Render theme css -->
{{ partial "css.html" . -}}

<!-- Render custom header -->
{{ partial "head.html" . -}}

<!-- Refer: https://regisphilibert.com/blog/2018/08/hugo-multilingual-part-1-managing-content-translation/ -->
{{ if .IsTranslated }}
{{ range .Translations }}
Expand All @@ -20,6 +17,11 @@

<!-- Add twitter card for logo and images. You can preview cards in the X compose window. -->
{{ template "_internal/twitter_cards.html" . }}

{{/* Math equation support. See <https://gohugo.io/content-management/mathematics/#step-3>. */}}
{{ if .Param "math" }}
{{ partialCached "math.html" . }}
{{ end }}
</head>
<body>
{{ block "navbar" . }}
Expand Down
14 changes: 0 additions & 14 deletions layouts/partials/head.html

This file was deleted.

11 changes: 11 additions & 0 deletions layouts/partials/math.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{/* See <https://gohugo.io/content-management/mathematics/#step-2>. */}}

<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
<script>
MathJax = {
tex: {
displayMath: [['\\[', '\\]'], ['$$', '$$']], // block
inlineMath: [['\\(', '\\)']] // inline
}
};
</script>