How to Use Latex in Jekyll
In Jekyll, we cannot simply write in Latex like how we do in the Markdown, like $$E=mc^2$$. There are two ways we can do. Both ways use the Mathjax.
Method 1:
The simplest and easiest is embedding the following code to your html webpage and replace the equation but you need to do it everytime when you create a new webpage.
make sure your webpage must be an HTML file, not an MD file.
Example
---
layout:
title: 
subtitle: 
---
<html>
    <head>
       <meta charset="utf-8">
       <meta name="viewport" content="width=device-width">
       <title>MathJax example</title>
       <script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-MML-AM_CHTML" async></script>
   </head>
   <body>
       <p>
          $$E=mc^2$$  
      </p>
  </body>
</html>
Just like this:
\(E=mc^2\)
Method 2:
Adding the following code to your _includes/head.html, and you don’t need to embed the mathjax everytime when you are creating a new page.
Your webpage can be an MD file. It enables you to write in  MD file like you do in Latex, like $$E=mc^2$$.
<!----Mathjax---->
 <script type="text/x-mathjax-config"> MathJax.Hub.Config({ TeX: { equationNumbers: { autoNumber: "all" } } }); </script>
  <script type="text/x-mathjax-config">
   MathJax.Hub.Config({
     tex2jax: {
       inlineMath: [['$','$'], ['\\(','\\)']],
       displayMath: [['$$','$$'], ['\[','\]']],
       processEscapes: true
     }
   });
  </script>
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>