Code injection. Ghost Newbie. Where to put javascript files (self hosted Ghost v4.12)

If you’re looking for help, please provide information about your environment. If you delete this template and don’t provide any information, your topic will be closed.

If you aren’t running the latest version of Ghost, the first thing we will ask you to do is update to the latest version of Ghost.

  • What’s your URL? Walks
  • What version of Ghost are you using? 4.12
    your topic

And

  • How was Ghost installed and configured? - Self hosted Ubuntu 20.04 Oracle VM
    How to install & setup Ghost on Ubuntu 16.04, 18.04 and 20.04

  • What Node version, database, OS & browser are you using? any browser

  • What errors or information do you see in the console? Error 404 for test1.js

  • What steps could someone else take to reproduce the issue you’re having?
    open page, check console for 404 error
    Walks

Ghost appears to be running normally.
I’m new to Ghost.
I’m using the default Casper theme.
I have created a walks page (not post) and I want to run a javascript file from the code injection
I’ve tried a variety of paths but get 404

Where do I post test1.js ?

This is my 1st step to having customised page that will replicate reading a json file
https://redbridgeramblers.org.uk/walks.html

I think we need to understand what you are trying to accomplish, as your message sounds there is more to come. So this may not be the solution for what you are trying to do.

As for loading a javascript file, within your Site Header or Site Footer section in Code injection you can put a script tag like:
<script src="{YOUR JAVASCRIPT URL}" />
if you need to upload a JS file to your theme and reference from there, you can use the ‘/content/themes/casper/assets/built’ directory. Save your external file there and use it as :
<script src="assets/built/test1.js"/>

@kose_mark is right. If this will be something you want to be independent of your theme though, you can alter some settings pretty easily and create a “static” files folder on your server for holding things like this.

There’s a great guide at Hosting static files on your Ghost blog

There isn’t a way within the Ghost interface to upload the files, but if you set this up, you can also set up SFTP access and then drop in whatever files you might need.