In your head.html page:
{% if page.mathjax %}
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: { inlineMath: [["$","$"],["\\(","\\)"]] },
"HTML-CSS": {
linebreaks: { automatic: true, width: "container" }
}
});
</script>
But in index.html, it can not expose an variable which is dynamically decided by the post pages to the page head.html which it include.
Inserting an if statment to index.html to parse the posts' excerpts may help.
OR
Record to site.data files when each post needs mathjax.
OR
In any case, inject the javascript statment of mathjax.