By clicking “Accept”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. View our Privacy Policy for more information.

Adding a copyright date programmatically in Webflow using JavaScript

A super easy JavaScript hack so you don't have to update the copyright date on yours or your client's sites every year.

  1. Firstly construct and style your copyright sentence as you'd like it to look.
  2. Then add a <span> div around where you'd like the date to feature.
  3. Give the span an id, in this example, I've called it currentYear.
  1. You can place the custom code you are about to write in the main project settings custom code area. This code will work perfectly well there. However, since this little hack is usually used in footers, and if you are developing in Webflow, your footers should be components by now, which will be identical wherever you place them by design. So I find it useful to keep this code local to the footer component by adding a custom code embed block inside, but at the very end of the footer component, as below.
  1. Place the following code inside that Embed block, or indeed in the main custom code block on the project settings page, if that's where you prefer it.

/* Get current year 
- Create a variable that holds the span element.
- Create a new Date() object and call the getFullYear() method on it.
- Place what is returned from that method call into the textContent of the span element. 
  let currentYearElement = document.getElementById('currentYear')
  currentYearElement.textContent = new Date().getFullYear();

  1. Publish your site and that's it. No more manually updating the copyright year.

You're all caught up.
There are no more recent posts.
That's everything.
There are no more articles, you've read them all!