digitalcraftsman / hugo-cactus-theme

Port of Nick Balestra's Cactus theme to Hugo.
MIT License
198 stars 111 forks source link

Feature for MathJax support #26

Closed rrampr-zz closed 7 years ago

rrampr-zz commented 7 years ago

Can we have mathjax support. I manually override the footer.html to do this, but it would be nice if it were inbuilt into the theme.

https://gohugo.io/tutorials/mathjax/

digitalcraftsman commented 7 years ago

Hello @rrampr,

have a look at the customJS option in the example config file. Just add the url to the MathJax script as string to list.

digitalcraftsman commented 7 years ago

The aforementioned solution should work fine. Feel free to reopen this issue if the approach doesn't solve your problem.

lukesmurray commented 6 years ago

Just want to leave this here for future people

Look in the root theme folder / layouts / js.html

There is the following lines.

{{ range .Site.Params.customJS }}
<script src="{{ $.Site.BaseURL }}{{ . }}"></script>
{{ end }}

The prefix {{ $.Site.BaseURL }} adds the site url to the links breaking any links to external cdn's and what not. So if you are linking to an external cdn using the following in config.toml

    customJS  = ["https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML"]

Then you need to change the lines in js.html to

{{ range .Site.Params.customJS }}
<script src="{{ . }}"></script>
{{ end }}