How can I inject code on custom pages / How can I load a javascript file on a custom page only

I’m trying to load a js file which should be loaded after the jquery file.

    <script src="{{asset "built/art-page.js"}}"></script>

If I add my js tag at the bottom of my custom.hbs, it will load before the jquery file.
A good place to add the code above would be in the “{{ghost_foot}}”.
Unfortunately I have no idea how to add code there on a custom page “custom.hbs”.

You should be able to add it to default.hbs. There, you should be able find where jQuery is being loaded and add the script after it.

Yeah I’m doing that now. But the thing is I’m loading js libraries and big js files for other pages which I’d like to separate to increase performance since they’re not used on the homepage.


This is a good context for using the {{{#block}}} helper. In your default.hbs file, add a block after the jQuery file like this;

{{{block "scripts"}}}

Then, in custom.hbs, add this:

{{#contentFor "scripts"}}
<script src=""></script>

Then, whenever your custom.hbs file is loaded, it’ll send that script up to default.hbs to be loaded. See more details here: Ghost Handlebars Theme Helpers: block & contentFor


I blunder my way through tech stuff and have a paid sight I’d like to add commento to. I think if I connect my home page it means I will have an option to have members comment on any page of the website (I hope). On the Commento website, I selected my home page. However when I add the universal HTML code to a new post, the Comment widget does not appear.
I think it is because I am doing step two and three below, but not the first one. Does anyone know where I can find information on how to install Commento on my server?
Installing a self-hosted instance of Commento can be divided into three logical steps:

  • On your server: The first step deals with installing Commento’s binary and files on your server and involves getting the backend running. This may be done with release binaries, Docker, or by compiling from source.
  • Register your website: Once you’ve installed an instance of Commento on your server, you must create an account to register the website where your readers will be adding comments. This step lets the Commento server know about your website so that it can serve requests.
  • Embed on your website: Finally, after registering your website, you can install Commento on your website to let your readers interact with your Commento instance. For now, Commento supports just one method of embedding: a universal tag that requires you to embed a <script> tag in your HTML. In the future, there will be direct plugin support for common platforms such as Wordpress, Blogger, Wix, and Ghost.

Alright that’s awesome and it did the trick!
Thanks again for the help champ!

1 Like

I think you made a mistake and commented on my post instead of creating your own post.

1 Like