Skip to main content

January 3, 2023

How to Keep the Copyright Date on Your Webflow Website Up-to-Date Automatically

3 min read

The code

<code>
<script> let yearElements = document.getElementsByClassName('year'); [].slice.call(yearElements).forEach(function (div) {   div.innerHTML = new Date().getFullYear(); });
</script>
</code>

Introduction

Most footer’s have the year in the copyright section of the website. It is easy to forget to make the change at the beginning of the year. Instead of adding one more item to our to-do list, we can have it update each year automatically.

Here is what you need to do in your Webflow project.

For starters, my Footer is a component. If you aren’t using components, you need to do use them. Components will save you so much time, especially when you need to make a change, like changing the date to reflect the new year.

I’m assuming your footer has been turned into a component. If it is not, you can click on the section, then click create component. Name it something descriptive, like footer. It doesn’t have to be revolutionary. It just needs to be something you can remember.

Once you have your footer turned into a component follow these steps. Here is a scribe I made. More instructions are to follow below the scribe as well as the code you need to paste in.

Instructions written out

NOTE:These are the same as above, but more detailed

(1) Click on footer in the navigator. Then in the right hand panel, click edit component. This step is crucial, so that you are editing the actual component and not just a field in the component.

(2) Click the plus icon on the left side bar or type “A” to open the Add panel. Scroll down to the advanced section and click on embed. This will put an embed element in your footer. The custom code section will pull up.

(3) Now paste this Javascript code into the code editor.

<code>
<script> let yearElements = document.getElementsByClassName('year'); [].slice.call(yearElements).forEach(function (div) {   div.innerHTML = new Date().getFullYear(); });
</script>
</code>

What this code does, is it updates any div with a class of year to the current year.

(4) Save and close the embed. Make sure the embed is at the bottom of the hierarchy in the navigator. It won’t affect the code and whether it works or not, but it will make the next step easier so that you can see the actual date since the back to instance bar opens at the bottom and gets in the way. At least it does in my project.

(5) Find the date in your footer.

(6) Highlight just the date you want to change.

(7) A menu will popup.

(8) Click the span icon to create a text span.

(9) Add the class of ‘year’ to the span using the style’s panel.

NOTE: The date won’t change. That doesn’t mean something is broken. The date is only going to change on the published site since it is a script.

(10) Publish your site.

(11) View the published site.

The date should have changed to the current year!

marketing health check clipboard showing score

Your Marketing Isn't Bringing in Leads and You Can't Figure Out Why

Score your marketing across 7 key areas in 5 minutes and find out exactly what's holding back your leads and what to fix first.

Questions You Might Be Asking

Scripts only run on the published site, not in the Designer canvas. Webflow strips or disables embedded JavaScript in the editor to keep the building experience safe and fast. Publish to your staging or production URL and view the live site to confirm the year is updating. That's the only reliable place to test.

Yes. getElementsByClassName returns every element with the matching class, so one script block covers all of them. Add the 'year' class to as many spans as you need — footer, terms page, privacy page — and a single embed in the footer component updates them all. That's why putting the script in a shared component is ideal.

Yes, with a small tweak. Replace new Date().getFullYear() with new Date().toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) for a full formatted date. Target a different class name like 'date' to avoid mixing the two. The same forEach pattern still applies.

None worth worrying about for a copyright footer. Googlebot renders JavaScript and will see the current year on live pages. If you're using the year in content that matters for ranking — like a title or H1 — hardcode it so crawlers see it immediately in the HTML and you can update it intentionally each year.

Stop losing deals to a website that's holding you back.

Book a 30-minute strategy session. You'll leave with a clearer picture of what your site needs to do and a rough budget range, whether you hire us or not.

background cta image collage of websites

Other posts in this category

Midlothian growing neighborhood with a map pin marking a local web design studio

Best Web Designers in Midlothian

Midlothian is one of the fastest-growing cities in North Texas, and "best web designer" depends on what your business actually needs. Here's the honest way to evaluate your options.

Business owner comparing web designer portfolios on a laptop near the Waxahachie courthouse square

How to Choose a Web Designer in Waxahachie

Waxahachie has grown almost 25% since 2020, and your website is how all those new neighbors find you. Here's a six-step process for choosing the web designer who'll get that right.

Split image comparing a Dallas web designer's build screen with a marketing agency's multi-channel campaign board

Dallas Web Designer vs Marketing Agency

A web designer builds the site and a marketing agency fills the funnel, but hiring the wrong one first costs you a year. Here's how Dallas businesses should decide, and why the real question is who owns your message.