Discourse + Ghost integration, console error

Folowing this page I used this code in order to integrate Discourse’s comments on my Ghost js V3 blog :

<div id='discourse-comments'></div>

<script type="text/javascript">
      if (window.location.pathname.indexOf('/p/') < 0) {
  DiscourseEmbed = { discourseUrl: 'https://forum.ghost.org/',
                     discourseEmbedUrl: '{{url absolute="true"}}';

  (function() {
    var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
    d.src = DiscourseEmbed.discourseUrl + 'javascripts/embed.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);

That it generates an error in the console :

embed.js:1 Uncaught TypeError: Cannot read property 'appendChild' of null
    at k (embed.js:1)
    at Object.l [as isSerif] (embed.js:1)
    at h.i.toJSON (embed.js:1)
    at Object.c.loadEmbed [as _loadEmbed] (embed.js:3)
    at embed.js:3

Any ideas to fix this ?

I put the code in the partials… maybe i should put it in “post.hbs”

1 Like

To solve the problem with Ghost templates, just put the code in post.hbs, not in comments.hbs