Automatically Updating the Copyright Year
In this guide, we'll add some code to your site so that you never have to worry about the copyright year being out-of-date.
Introduction
As we approach the New Year, there's a task that many forget... updating the year in the copyright notice on websites. The number of sites I see that are at least a year out-of-date is pretty astonishing!
It seems like a small thing, but to me, seeing last year's date in the footer hints at a site that is not well maintained, and immediately makes me worry about other issues the site may have.
So let's look at how to add a little bit of code so that you don't have to remember to update the year manually...
Please note that this code cannot be applied to Squarespace websites on the "Personal" plan, as it requires access to the Code Block and Code Injection.
Step 1 of 2. Add the HTML
- Log in to Squarespace, then go to Pages and select any page.
- Scroll to your footer, click Edit and add a Code Block.
- In the Code Block, paste in the following code. We'll go through it in a moment.
<p> © ABC Company Limited <span id="copyYear"></span> </p>
- Click Save on the Code Block, then save the changes to the page.
- Note: The year will not be showing at the moment. Step 2 will solve this.
Code Explanation
- The code starts with a paragraph tag <p>. This can be omitted, but gives you the option of adding additional styling if you need to. Remember to close it out with </p>.
- The © is HTML code for the copyright symbol (©).
- Obviously, replace ABC Company Limited with your own company name.
- The remaining code, <span id="copyYear"></span> is where the magic happens!
Step 2 of 2. Add the JavaScript
- Go to Settings > Advanced > Code Injection
- In the section marked FOOTER, paste the code snippet and click Save. It will look like this:
<script type="text/javascript"> var currentYear = new Date().getFullYear(); document.getElementById("copyYear").innerHTML = currentYear; </script>
This code dynamically calculates the current year, then adds it as text to the <span> we created in Step 1. The result will look like this...
© ABC Company Limited
I hope you find this Squarespace Guide helpful. If you're having any problems, I would be happy to help. You can leave a comment below, send me a message on Twitter or use the contact form here.