Adding Math to my jekyll webpage

Posted on: 17 Aug 2022

By default it was not possible to use math equations in the markdown Jekyll blogs. I was using github readme markdown earlier and there it supports the typical Latex math text.

So to solve any problem in my life, I google and found the solution right away. Thanks to this person’s comment here and this blog here. Both essentially say the same thing.

Add a directory called

"_includes\scripts.html"

Edit the html with


<script type="text/javascript" async
  src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>

This would allow you to use mathjax library to write equations. You just have to had the following in the YAML

---
mathjax: true
---

Fun fact:

YAML stands for yet another markup language or YAML ain’t markup language (a recursive acronym)

YAML stuff is on the top of every markdown files adding data

My first attempt to write equations

$$ a = 1 $$
$$ b = 2 $$
$$ a + b = 3 $$

\(a = 1\) \(b = 2\) \(a + b = 3\)

It works great. I will use the following webpage as Mathjax reference:

It was little scary for me as a new user to jekyll to add an extra directory like include and scripts.html. Because in past, every time I add something like this the whole site stops functioning properly. I am glad that it worked properly and in the future I might be able to add more scripts like this.