Updating Copyright Year automatically

As a website owner, keeping your copyright information up-to-date is essential. One way to ensure your footer always displays the current year is to use a simple JavaScript code. This guide will walk you through implementing this on your Squarespace site.

Prerequisites

Before you begin, please make sure your Squarespace account is at least on a Business subscription. Custom code is necessary to add to your website.

Step 1: Locate the Footer

Log in to your Squarespace account and navigate to the website you want to update. In the Squarespace editor, find the section of your site that contains the footer.

Step 2: Open Code Injection

To access Code Injection in the Squarespace editor, you can follow these steps: The easiest way is to click anywhere in the left-side menu bar and press the forward-slash ("/") on your keyboard. This will prompt a search box. Type "Code Injection" and click on the suggested option. OR Scroll to the bottom of your pages, and under Website Tools, select Code Injection. This will take you to the Code Injection section, where you can insert the provided JavaScript code.

Step 3: Insert the Code

Copy the following JavaScript code:

<script>
    document.addEventListener("DOMContentLoaded", function() {
      var currentYear = new Date().getFullYear();
      document.getElementById("currentYear").innerText = currentYear;
    });
  </script>

Return to the Code Injection section in Squarespace and paste the code into the Footer section.

Step 4: Update Your Footer

Ensure your footer HTML includes a <span> element with the ID "currentYear" where you want the year to appear. For example:

<p>Copyright Company Name <span id="currentYear"></span> - All rights reserved.</p>

Step 5: Save Changes

Click Save to apply the changes to your Squarespace site.

Whenever someone visits your site, the JavaScript code will dynamically update the year in your footer to the current year.

That's it! You've successfully set up an automatic copyright year update for your Squarespace website. This simple addition helps ensure that your site always reflects the current year without manual intervention.

Previous
Previous

What’s the Best Editing Software for Professionals?