Help with Bokeh shortcode

Apologies to go back to this old topic.
Is this shortcode for Bokeh still working? I’m having problems with my site.

Thank you!

What does this mean?

I either get nothing as output in the site or an error message.
I’m building my site on Netlify (Wowchemy theme).

Error: Error building site: “/opt/build/repo/content/graficos/”: failed to render shortcode “bokeh”: failed to process shortcode: “/opt/build/repo/layouts/shortcodes/bokeh.html:11:33”: execute of template failed: template: shortcodes/bokeh.html:11:33: executing “shortcodes/bokeh.html” at <$item.RelPermalink>: nil pointer evaluating resource.Resource.RelPermalink

How are you calling the shortcode?

1 Like


First, thank you for taking the time to have a look at this.

I’m calling the shortcode “bokeh.html”.
I have limited coding skills, and I can’t make much sense of how this shortcode works.

{{ $item := $.Page.Resources.GetMatch (.Get 0)}}

<div id="{{ .Get 0 }}">

  <script charset="utf-8" type="text/javascript">

    var xmlhttp = new XMLHttpRequest();

    xmlhttp.onreadystatechange = function() {

      if (this.readyState == 4 && this.status == 200) {

        var item = JSON.parse(this.responseText);

        Bokeh.embed.embed_item(item, "{{ .Get 0 }}");


    };"GET", "{{ $item.RelPermalink }}", true);




I also added Bokeh’s “scripts” to the custom head

What does your markdown file look like?

Right now I’m just trying to have the graph show in the website.

{{% bokeh "PBI real.json" %}}

I tried different paths to the .json file. In some instances nothing happens (the site builds), in other instances I get the above error message.

This is my custom head:

<script type="text/javascript" src="" ></script>
<script type="text/javascript" src="" ></script>
<script type="text/javascript" src="" ></script>
<script type="text/javascript" src="" ></script>

Do you have a git repository for your project’s source code? If so, is it public? If so, can you share a link to it?

Here GitHub’s repository:

Path to the markdown file:

A number of .png files that work just fine. The shortcode is at the end of the file.

Shortcode in “layouts/shortcodes”

Change this:

{{% bokeh "PBI real.json" %}}

to this:

{{< bokeh "PBI real.json" >}}

Reload the page, and open the dev tools. You’ll see this error:

So, to answer your original question, this shortcode and/or the associated scripts are not working.

And before you begin troubleshooting, rename your data file to eliminate the space and upper case. Something like pbi.json.

Thank you, this provides some new information.
I wish there were an easier way to make this work.

Hope you have a nice week.


OK, this works.

You can name your JSON file whatever you would like, including spaces and upper case characters, but I stand by my earlier recommendation—it is the right thing to do.


└── post
    └── test
        └── pbi_real.json


{{< bokeh "pbi_real.json" >}}


{{- with .Get 0 -}}
  {{- $path := . -}}
  {{- $id :=  anchorize . -}}
  {{- with $.Page.Resources.GetMatch $path -}}
    {{- $json := .Content | safeJS -}}
    <div id="{{ $id }}">
        var item = JSON.parse({{ $json }});
        Bokeh.embed.embed_item(item, {{ $id }});
  {{- else -}}
    {{- errorf "The %s shortcode was unable to find %s. See %s" $.Name $path $.Position -}}
  {{- end -}}
{{- else -}}
  {{- errorf "The %s shortcode requires a single positional parameter. See %s" $.Name $.Position -}}
{{- end -}}

And this should be in the <head> section of your page:

  <script src="" crossorigin="anonymous"></script>
  <!-- <script src="" crossorigin="anonymous"></script> -->
  <!-- <script src="" crossorigin="anonymous"></script> -->
  <!-- <script src="" crossorigin="anonymous"></script> -->

I’ve commented out the last three items because they are not needed for your chart, but you might need them for something in the future.


Open your JSON file and go to the very end. Notice the version, 2.3.0. The script(s) that you load in <head> need to match.

1 Like

Yes! Thank you so much!
I need to figure out to fix the size. The chart shows too wide and does not show up completely.

PS: I do appreciate the help/guidance in what is a new language and methods for me.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.