How to get Obsidian to recognize publish.js file for upload?

I’m running insider build v0.11.10 the release notes say

Option to run JavaScript on your site, by uploading a file named publish.js in the root of your vault. Note that this is only available for sites under a custom domain.

My site is set up on a custom domain (https://longpressed.com) and is also redirected from 🏠 Start Here - Long Pressed. I was able to set up the GA ID and get that working.

I’m trying to get custom JavaScript to run on my site now.

Things I have tried

I have a JavaScript file called publish.js in the root of my Vault, similar to obsidian.css. It has a few lines of JavaScript in it. When I click publish, I see the obsidian.css file but not the publish.js file. I originally created the file in Obsidian which called it publish.js.md but I renamed it and edited it in WebStorm instead.

I’ve searched the Help vault that comes with the insider build as well as the forum. I’ve even tried renaming it to obsidian.js in case that was a typo. I’ve restarted Obsidian and I’ve looked under both unchanged and new menus. I’ve also checked to see if something needed to be enabled in my vault settings and in my site options.

you have to wait until 0.11.11 because we made a mistake with the upload procedure of publish.js.
Sorry!

2 Likes

This is happening to me right now.

Here is a test site: Obsidian Publish

I published a css and a js file. The css file works, and is changing the title to red, but the js is not being run. I don’t know what to do?

I can also see the file does exist in a route identical to the publish.css file:
https://publish-01.obsidian.md/access/22f078957f9fe2938b4615a983ef8170/publish.js

It just isn’t being loaded.

Any help is appreciated.

1 Like

Wanted to bump this because I’m running into a similar issue I think.

publish.js doesn’t seem to do anything. Even if I simply use a console.log(“test”), nothing is logged in the console when I visit my site.

Using Obsidian v0.15.9