# Including mathjax: managing headers and footers?

To include mathjax, I have a file mathjax.html which I place in the layouts/partials directory of my theme, and include the line

{{ partial "mathjax.html" . }}


in the thtme’s header.html file. This works perfectly, but it means that if I want to change themes I have to ensure mathjax, and that line, is available to the new theme.

Is there a way of including partials which is theme agnostic - so is available to every theme? That is, if I include all this in my site’s layouts/partials/header.html file, will this conflict, or be read before (or after) the theme’s header file? I’m not sure how mutliple headers and footers are managed.

See the docs on Lookup Order for info.

You don’t need to ensure that the mathjax portion is included in all the themes… just put the mathjax.html in your <SITE>/layouts/partials/ dir… you don’t need to copy to each theme.

About “and that line, is available to the new theme.”: Depending on the theme, that same step might not even work… some themes might be referring to header.html partial, and some head.html partial, and some not even that. Some themes might use the more recommended baseof.html/block/define approach that might not use partials for this at all, and some theme might just read in the <script> content from your site config.

So there isn’t just one way to do what you want. If you switch themes, some maintenance might be involved. Normally, people try out various themes, stick to one and then fork that one theme to adjust it to their liking.

As explained above, no (unless you completely override a higher order layout file like single.html in your <SITE>/layouts/… which would be odd… because then your overriding template might not necessary blend well with the theme, or might not even be compatible).

It won’t conflict.

IF the theme is using header.html partial, it will use the version in your <SITE>/layouts/partials/ directory instead of the one in <SITE>/themes/<THEME>/layouts/partials/. If not, then your <SITE>/layouts/partials/header.html will do nothing.

Just try it out!

Well, I couldn’t have wished for a more complete, detailed, and excellent explanation as that - thank you very much! Well, I’m still very much in the explanatory stage, so I’ll see what happens when I do, as you say, try it out!

Again, thank you very much for your time and trouble.