How to include a script on only one content page?

I have one particular content page that needs a script that isn’t used on any other page. How do I include it when it uses the same template as all the other pages?

I do this in my Zen theme for the javascript needed on contact form pages.

I wrap the code to add the script tag in an if statement that checks for a parameter. Then I set that parameter in the front matter on the page(s) I want it to load.

In this example the parameter is “contactform” so I set “contactform: true” in the front matter.

2 Likes