Hugo

Inner javascripts in shortcodes shows as PRE

How can I avoid having my inner javascript in a shortcode show encapsulated within <pre></code>?

<script>
alert...

Shows as

<pre><code>alert...

If I add my JS inside a partial I get these:

var iframe = document.getElementById(&lsquo;iframe&rsquo;)

Instead of:

var iframe = document.getElementById('iframe');

you give us only a small part information to help you …

this is my template to show panorama pictures … Compare and try to fix your template

{{ define "main" }}
<header>
	<h1><span class="dn di-l">{{ site.Title | markdownify }} &nbsp;</span><i class="fas fa-dragon fa-fw"></i>&nbsp;&nbsp;{{ .Page.Title | markdownify}}</h1>
	{{ partial "single-head" . }}
</header>
<article class="bt bb bw2 b--blue">
	{{ .Content }}
	<br/>
	<div id=osd class="ba vh-50 w-100"></div>
	<script src=https://cdnjs.cloudflare.com/ajax/libs/openseadragon/2.4.1/openseadragon.min.js ></script>
	<script>var viewer = OpenSeadragon({id:"osd",showFullPageControl: false,prefixUrl:"https://cdnjs.cloudflare.com/ajax/libs/openseadragon/2.4.1/images/",tileSources:"/panorama/{{.Params.directory}}/dzc_output.xml"});</script>
</article>
{{ end }}
1 Like