Skip to main content

How to add a script to the Head of your docusaurus site

It's important to know how to add scripts to the Head of your website. This is where you will typically find your site presets, accessabitliy, head tags, and other scripts. This tutorial will show you how to add a script to the Head of your docusaurus site, specifcally a falling snowflakes script. You can find the docs for how to do this here.

Summary

Example 1: Snow Falling Effect

I came across https://embed.im/snow/ on Twitter and thought it would be a fun way to add some Christmas cheer to my site. It was posted by @JoshWComeau. He's a good follow. Here is the tweet. Below you'll find a simple script that you can add to your docusaurus site to add a falling snow effect to your site.

Copy and add this code to the docusaurus.config.js file. Specifically within the const config = { } object.

scripts: [
// String format.
"https://docusaurus.io/script.js",
// Object format.
{
src: "https://app.embed.im/snow.js",
defer: true,
},
],