How to add custom javascript to Hugo

teamallnighter

Chris Connelly

Posted on September 30, 2020

How to add custom javascript to Hugo

Add the following to your config.toml

custom_js = ["js/custom.js"]
Enter fullscreen mode Exit fullscreen mode

in your head.html

{{ range .Site.Params.custom_js -}}
    <link rel="stylesheet" href="{{ . | absURL }}">
{{- end }}
Enter fullscreen mode Exit fullscreen mode

Under static -->js
save your custom.js file!

Rebuild

💖 💪 🙅 🚩
teamallnighter
Chris Connelly

Posted on September 30, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related