Sign in

I want to run JavaScript on my pages

  • This topic has 6 replies, 2 voices, and was last updated 1 year, 6 months ago by .
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #7537
    Avatar photoResearchBuzz

    Hello,

    I’ve got some JavaScript doodads I want to run on my pages. They’re basic and self-contained scripts.

    I went looking for some information on this. I found https://getpublii.com/dev/how-to-add-custom-config-or-js-for-post-editor/  but I wasn’t sure if that was applicable to what I want to do.

    Am I missing the correct documentation? If someone can point me in the right direction I’ll take a pop at figuring it out myself.

    thank you.

     

    #7538
    Avatar photoBob

    Just use the Custom HTML tool → https://getpublii.com/docs/tools.html#customhtml

    --
    Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!

    #7539
    Avatar photoResearchBuzz

    I’m sorry, I’m not sure that applies to what I’m doing. I want to put different scripts on different posts. This looks like it’s for HTML sitewide?

     

    You must think I’m quite stupid, I apologize.

    #7540
    Avatar photoBob

    I’m afraid, by default there is no way to put different scripts on different post pages.
    Custom HTML tool places your script/s in dedicated rooms like header, footer, body …

    You will have to play around with the post config option to create a dedicated “room” for your scripts and then you will be able to paste different codes into different posts.
    More about it: https://getpublii.com/dev/post-config-options/#post-config-options

    --
    Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!

    #7541
    Avatar photoResearchBuzz

    Thank you. Would the simplest thing be to put all my scripts in one js file and apply that globally using the Custom HTML tool? They’re already set up as functions.

    #7542
    Avatar photoBob

    Upload your e.g. script_name.js using File Manager, then use the Custom HTML tool (move it to the footer) to add this file as follows:

    <script src="../../media/files/script_name.js"></script>

     

    --
    Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!

    #7543
    Avatar photoResearchBuzz
    This reply has been marked as private.
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.