Keep the year in your footer updated automatically with this simple script

July 8, 2023

Here is a simple process to add a free custom script to your site and avoid an awkward out of date footer.

Step 1:  Add your footer text with a <span> element wrapped around the year with an id attribute.

Example: <p>Copyright ©<span id='year'>0000</span>All Rights Reserved</p>

The id and placeholder text can be whatever you wish, the important thing is to match the id with the JavaScript

Step 2: Add an EMBED block with this script code:


// Get the current year (This uses your browser to access what year it currently is)

const currentYear = new Date().getFullYear();

// Find the element by its ID (here is where we connect to the text element from step 1. Make sure the id's match.)

const yearElement = document.getElementById("year");

// Replace the text with the current year (this is where the JavaScript comes in and replaces the 0000 with the current year. This should happen so quick that you never see the 0000)

yearElement.textContent = currentYear;


Now you have an auto updating footer