felipe1
felipe1
CDCloudflare Developers
Created by dok on 10/17/2024 in #pages-help
How do you set the "copyright year" dynamically in Pages?
Hey, you dont need to hard code the year, just use plain javascript for it in the frontend side, add a js file in your static files, add the script in all pages that you want to show the actual year and add an id in a span so that it render the year automatically like this: js file: let currentDate = new Date(); let currentYear = currentDate.getFullYear(); let currentYearElement = document.getElementById("currentYear"); currentYearElement.textContent = currentYear; and then in the footer script on each html static file: <div class="footer-2"> <p class="footer-2-p-text-1"> Copyright <span id="currentYear"></span> | Copyright | Website name etc </p> ... etc and then: <script src="/js/year-code.js"></script>
11 replies