I used the directions here:
  
  
    
  
  
    
    
      
        opened 03:38AM - 03 Sep 18 UTC 
      
        
          closed 03:43PM - 03 Sep 18 UTC 
        
      
     
    
    
   
 
  
    The Hugo documentation says to put 
```
<script type="text/javascript" src="ht… tps://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
```
in a partial layout that will appear on every page that you need the mathjax, but I can't figure out how to make this repository a submodule and at the same time add mathjax support. 
   
   
  
    
    
  
  
 
But they don’t work anymore.
As well, I tried:
https://geoffruddock.com/math-typesetting-in-hugo/ 
But at the end it says to “modify your CSS” file, which one?
Perhaps one you set here?
At any rate, there doesn’t seem to be a standard way to enable LaTex, pointers?
Thanks,
             
            
              
            
           
          
            
              
                ju52  
              
                  
                    May 20, 2022,  8:12pm
                   
                  2 
               
             
            
              back to the roots
Add the scripts to your page template …
for the first start put it in layouts/_default/single.html
             
            
              
            
           
          
            
            
              Putting either v2 or v3 script from the MathJax link above into layouts/_default/single.html causes all pages to be blank.
             
            
              
            
           
          
            
              
                ju52  
              
                  
                    May 21, 2022, 12:13pm
                   
                  4 
               
             
            
              create a litle sample project on GitHub, so we can help
I use the scripts in may samples , if you want to see it working
PS: I trigger the script include and activation by using a {{<tex>}} shortcode
             
            
              
            
           
          
            
            
              Well, my blog  is pretty small but has two LaTeX-intensive pages:
             
            
              
            
           
          
            
            
              I added layouts/js/mathjax.html, layouts/partials/meta.html, layouts/partials/preload.html, and layouts/shourtcodes/tex.html taken from your examples. Amusingly, it renders LaTex in my local preview pane from FrontMatter, but not on the site itself.
             
            
              
            
           
          
            
              
                ju52  
              
                  
                    May 22, 2022,  5:16pm
                   
                  7 
               
             
            
              change site-scripts to
{{ $script := .Site.Data.webpack_assets.app }}
{{ with $script.js }}
     <script src="{{ relURL (printf "%s%s" "dist/" .) }}"></script>
{{ end }}
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({ tex2jax: {inlineMath: [["$$","$$"],["\\(","\\)"]]} })
</script>
and it works…   AND changed single $ to double $$
Check .Site.Data.webpack_assets.app !  And better to use the newest MathJax version!
Good Luck!
             
            
              1 Like 
            
            
           
          
            
            
              Thank you, that worked!
Just as a note, switching $ to $$ doesn’t preserve inline behavior; here’s the script that did.
{{ $script := .Site.Data.webpack_assets.app }}
{{ with $script.js }}
<script src="{{ relURL (printf " %s%s" "dist/" .) }}"></script>
{{ end }}
<script type="text/javascript"
  src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
  </script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({ tex2jax: {inlineMath: [["$","$"],["\\(","\\)"]]} })
</script>
 
            
              1 Like 
            
            
           
          
            
            
              And to be clear, layouts/js/mathjax.html, layouts/partials/meta.html, layouts/partials/preload.html, and layouts/shortcodes/tex.html were all unnecessary … just the correct layouts/partials/site-scripts.html.
             
            
              
            
           
          
            
              
                ju52  
              
                  
                    May 22, 2022,  6:39pm
                   
                  10 
               
             
            
              YES, i tryed to made the pages faster,  embed scripts only  if needed etc …
             
            
              
            
           
          
            
              
                system  
              
                  
                    May 24, 2022,  6:40pm
                   
                  11 
               
             
            
              This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.