However it will only display the year when the website was last built! It will only update next time
you rebuild your site.
The solution
The solution is to use client-side JavaScript to get the current year when the page loads.
We prepare a date fallback at build time. If the user’s browser can’t run JavaScript,
we need to show the last known date.
We write the markup. We have a span with an id of footer-year so that it can be referenced
from our script. It has a default value of the fallback date of step 1.
In our script we can get the <span> element by its id and update its content to the current year.
The code differs depending on your Astro version, and whether you’re using View Transitions.