Your sites Log in Sign up Menu

How to install a third-party script on a template?

Can you give an example of how to add a javascript library to a site?


2 years ago, 1 replies   Improve this question

Let's say you want to install the library instant.page on your website. Their documentation tells us we need to add the following just before our site's </body> tag:

<script src="//instant.page/5.1.1" type="module" integrity="sha384-MWfCL6g1OTGsbSwfuMHc8+8J2u71/LA8dzlIN3ycajckxuZZmF+DNjdm7O6H3PSq"></script>

Let's assume you're using the Blog template. You'll first need to 'Fork' an editable copy of the template on your Template settings page.

Open up the template editor and navigate to the 'Source code' tab in the sidebar. Then find the template file footer.html, which contains the code used to render the bottom of your blog's layout (i.e. the footer, as opposed to the header).

You will want to insert the HTML required by instant.page into this file, which will be included in every page rendered on your site. In the case of the Blog template, the resulting footer.html file should look like this once you're done:

<script src="{{{scriptURL}}}" type="text/javascript"></script>
<script src="//instant.page/5.1.1" type="module" integrity="sha384-MWfCL6g1OTGsbSwfuMHc8+8J2u71/LA8dzlIN3ycajckxuZZmF+DNjdm7O6H3PSq"></script>

Does that help? Please let me know if you have any questions about this or anything else

Answered 2 years ago · Improve this answer